Skip to content
Advertisement

When a subclass is instantiated, is only one object created?

Since many constructors also call the superclass constructor, it seems like one could think that both the subclass and the superclass are instantiated when a subclass is instantiated; i.e. more than one object is created.

Is still just one object created?

Thank you

Advertisement

Answer

Just one object, even if the super’s constructor is called you are just performing additional instantiation on the one object.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement