The Constructor Invoked by super()

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.

Answer:

It is called super() because the parent of a class is sometimes called its superclass.

The Constructor Invoked by super()

A constructor for a child class always starts with an invocation of one of the constuctors in the parent class. If the parent class has several constructors then the one which is invoked is determined by matching argument lists.

For example, we could define a second constructor for Movie that does not include an argument for length. It starts out by invoking the parent constructor that does not have an argument for length:

// alternate constructor
public Movie( String ttl, String dir, String rtng )
{
  super( ttl );    // invoke the matching parent class constructor  
  director = dir;  rating = rtng;     // initialize members unique to Movie
}

QUESTION 12:

Does a child constructor always invoke a parent constructor?