When we instantiate a Child class object, the parent class's constructor is also called. So is it a creation of an object of the parent class?
Asked
Active
Viewed 138 times
0
-
A constructor doesn't instantiate a class, it initializes an instance. When the super constructor is invoked, it is invoked to initialize the parent aspect of the instance. – Sotirios Delimanolis Mar 21 '14 at 19:30
-
2Nope. There is only one object, but both constructors are being called on it. – Louis Wasserman Mar 21 '14 at 19:30
-
then who is the responsible for instantiate a class ? – Kalhan.Toress Mar 21 '14 at 19:44
-
answer is here http://stackoverflow.com/questions/17877615/how-many-objects-are-created-due-to-inheritance-in-java – lakshman Mar 21 '14 at 19:51
1 Answers
0
according to this question when you instantiate child class using new operator only child class object will create. you can think as parent constructor code is in child constructor code because of inheritance
-
`only child class object will create` doesn't feel complete to me. Especially since `child instanceof parent` will return true. – Cruncher Mar 21 '14 at 20:43