It is called super()
because the parent of a class
is sometimes called its superclass.
super()
A constructor for a child class always starts by invoking a constructor of the parent class. If the parent class has several constructors then the one which is invoked is determined by matching the argument lists.
For example, there could be a second constructor for Movie
that omits the argument for length.
It starts out by invoking the parent constructor that also
omits the argument for length:
class Video { private String title; // name of the item private int length; // number of minutes private boolean avail; // is the video in the store? // constructor public Video( String ttl ) { title = ttl; length = 90; avail = true; } // constructor public Video( String ttl, int lngth ) { title = ttl; length = lngth; avail = true; } . . . } class Movie extends Video { private String director; // name of the director private String rating; // G, PG, R, or X // 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; } . . . }
Does a child constructor always invoke a parent constructor?