Does an instance of superclass get created when we instantiate an object?

A single object is created – but that object is an instance of both the superclass and the subclass (and java.lang.Object itself). There aren’t three separate objects. There’s one object with one set of fields (basically the union of all the fields declared up and down the hierarchy) and one object header.

The constructors are executed all the way up the inheritance hierarchy – but the this reference will be the same for all of those constructors; they’re all contributing to the initialization of the single object.

Leave a Comment