go to previous page   go to home page   go to next page

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 constructors in the parent class. If the parent class has several constructors then the one which is invoked is determined by comparing the 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;   // initialize members unique to Movie
  rating = rtng; 
}  

QUESTION 12:

Does a child constructor always invoke a parent constructor?