Skip to Main Content

Inheritance

Cindy_PaulMay 3 2016 — edited May 3 2016

class A

{

int x;

int y;

void test1()

{

...

}

}

class B extends A

{

void test2()

{

.......

}

}

class C extends B

{

C o = new C();

o.x;

void test3()

{

....

}

}

My question is ..

|)" new C()" will create a new object of type C  on the space in JVM called heap .. this object on the heap will have :

1)int x, int y

2)test2()

3)test3()

OR

only test3()

===========================================

||) o.test2() .. this has the reference o calling the test2() method .. so will it be calling from the object of class B sitting on the JVM heap or it will be calling from the class C object which is in heap.

Comments
Post Details
Added on May 3 2016
4 comments
978 views