Hi,

why in this examples  the variable r which is in parent used ?



 class Q16
   {
       public static void main(String args[])
       {
          A a = new B();
          a.callme();
          System.out.println(a.r);

          a.xx();
       }
   }


class A
   {
     void callme()
     {
         System.out.println("A");
      }
    int r=10;



    }
    class B extends A
   {
      public void callme()
      {
         System.out.println("B");
      }
         int r=20;


   }


output :
B
10

Thanks,



On Sun, Jan 3, 2010 at 8:55 PM, SAADELDIN SULIMAN <
[email protected]> wrote:

> superclass classname=new subclass()
>
> there is inheritance
>
> Please read about inheritance.
>
>
>
> thanks
>
> Suliman
>
>
> On Sat, Jan 2, 2010 at 1:01 PM, nn roh <[email protected]> wrote:
> > What is the difference if we define the class as
> >
> > superclass classname=new subclass()
> >
> > subclass classname=new subclass()
> >
> >
> > Thanks;
> > Nada
> >
> > --
> > To post to this group, send email to
> > [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]<javaprogrammingwithpassion%[email protected]>
> > For more options, visit this group at
> > http://groups.google.com/group/javaprogrammingwithpassion?hl=en
>
-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to