9.5 Constructors in Subclasses

As we explained, instantiating a subclass object begins a chain of constructor calls in which the subclass constructor, before performing its own tasks, explicitly uses super to call one of the constructors in its direct superclass or implicitly calls the superclass's default or no-argument constructor. Similarly, if the superclass is derived from another class—true of every class except Object—the superclass constructor invokes the constructor of the next class up the hierarchy, and so on. The last constructor called in the chain is always Object’s constructor. The original subclass constructor’s body finishes executing last. Each superclass’s constructor manipulates the superclass instance variables that the ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.