AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



corejava-inheritance: How many objects will be created in multilevel inheritance?

class A{

}
class B extends A{

}
class C extends B{

public static void main(String s[]){

C c =new C();

}
}
If i create a object of class C then how many objects would be created internally?

corejava x 353
inheritance x 7
Posted On : 2014-05-14 17:10:55.0
profile Saksham Kumar - anyforum.in Saksham Kumar
73433936114
up-rate
-3
down-rate

Answers


Only one object will be created that is of class C only. The concept is whenever a child class constructor is called it calls its parent class constructor. super() is by default inserted in child class constructor. It doesn´t mean that a separate parent class´s object will be created. It is to include the property or behaviour of parent class in child class object, that´s it.

Posted On : 2014-05-14 17:23:33
Satisfied : 3 Yes  1 No
profile Rishi Kumar - anyforum.in Rishi Kumar
523188245674
Reply This Thread
up-rate
4
down-rate



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in