SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie wrote:I did say I thought my answer wasn't accurate.
Campbell Ritchie wrote:
Are you sure, Prabz Bhatia, that an object is created for each class in its inheritance hierarchy?
Prabz Bhatia wrote:Yes, I am sure, objects for all non abstract classes upwards the inheritance tree are instantiated whenever an object is created... Proof can be had from the following example
Joanne
Joanne Neal wrote:
Actually that's wrong. Despite their name, constructors do not create objects, they only initialise them.
A child class will contain all the instance variables defined in the parent class, but an instance of the parent class will not be created, so when you call the parent constructor you are actuall still initialising the child class.
See section 12.5 of the Java Language Specification for full details of what happens when an instance of a class is created.
Of, involving, or depending on a context
The circumstances in which an event occurs; a setting.
I want my playground back. Here, I'll give you this tiny ad for it:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|