package inheritance

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hostel
    New Member
    • Feb 2007
    • 17

    #1

    package inheritance

    hi,
    "a1" and "a2" in different source file.
    /* package p1;
    class a1 . */

    /* package p1
    class a2 extends a1*/

    when i compiled a2 source file i got error saying "unresolved symbol"

    plz tell me what to do , where i went wrong ..

    thank u
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by hostel
    hi,
    "a1" and "a2" in different source file.
    /* package p1;
    class a1 . */

    /* package p1
    class a2 extends a1*/

    when i compiled a2 source file i got error saying "unresolved symbol"

    plz tell me what to do , where i went wrong ..

    thank u
    You should compile a1 first.

    Comment

    • hostel
      New Member
      • Feb 2007
      • 17

      #3
      Originally posted by r035198x
      You should compile a1 first.
      a1 can be compiled without error when included package , but when i compile a2 including package name , then i get error saying "unresolved symbol". when i dont include package name then
      they compile and run

      Comment

      • dmjpro
        Top Contributor
        • Jan 2007
        • 2476

        #4
        plz send me the code...
        then i can explain u clearly...
        and one more thing , plz mention the jre environment and default classpath ............... ..
        send me my requirements i am online
        thannnkkkkkkkkk kkkkkkkssssssss sssssssssssssss sss

        Comment

        • hostel
          New Member
          • Feb 2007
          • 17

          #5
          Originally posted by dmjpro
          plz send me the code...
          then i can explain u clearly...
          and one more thing , plz mention the jre environment and default classpath ............... ..
          send me my requirements i am online
          thannnkkkkkkkkk kkkkkkkssssssss sssssssssssssss sss
          //file name a1.java
          package p1;
          public class a1{
          int a=1;
          public int b=2;
          private int c=4;
          protected int d=3;
          public a1()
          {
          System.out.prin tln("a="+a+"b=" +b+"c="+c+"d="+ d);
          }
          }

          //file name a2.java
          package p1;
          class a2 extends p1.a1
          {
          a2()
          {
          System.out.prin tln("a="+a);
          }
          }

          //file name demo.java
          package p1;
          public class demo
          {
          public static void main(String args[])
          {
          a1 ob1=new a1();
          a2 ob2=new a2();
          }
          }

          CLASSPATH
          /bin/jdk1.6.0/bin/ //for jdk
          /bin/jdk1.6.0/jre/lib/ //for runtime
          .:/wind/javapgm/ //package p1(directory) exists in javapgm

          Comment

          Working...