Superclass Collaboration
Eventually, a constructor always collaborates with one of its superclass's constructors. If a class has no declared constructor, Java supplies a default one equivalent to a constructor with no arguments and no statements. If the first statement in a constructor is anything other than a specific invocation of another constructor, Java inserts a call to super(), the superclass's constructor with no arguments. This causes a compilation error if the superclass does not provide a constructor with no arguments.
In Figure 14.1, for example the classes capture the idea that a fountain is one type of firework. (A fountain is a ground-based firework that emits a spray of sparks.) Suppose that at an early stage of development, we ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access