but that is not the syntax Java uses to call the superclass constructor. Instead, use:
super (n, d);
Thus, to call a constructor of the superclass, write a conventional call to the
superclass constructor but replace the name of the class name with super . Note
that there is no period following keyword super , as there is in the other use of
super (see Sec. 4.1.1).
If you do not call a superclass constructor
The first statement of a subclass constructor must be a call on a superclass
constructor. If you do not put one in, Java inserts this one:
In this case, the superclass must have a constructor with no parameters —if
not, the program is illegal and a syntactic-error message will appear when you
try to compile the program. The error message may be so confusing that you have
trouble determining what the mistake is —unless you remember the rules that
Java inserts a superconstructor call if you do not. This error will happen more
often than you expect, unless you get in the habit of explicitly writing a call to
the superclass constructor as the first statement in the subclass constructor.
Casting about, or about casting
Apparent and real classes
An instance of class Executive of Fig. 4.1 can be created and stored using an
initializing assignment like
Executive c= new Executive("Gries", 1966, 25000);
An executive is an employee; in the same way, we say that an instance of class
Executive , like c , is also an Employee . And, we can assign it to an Employee
toString() getBonus() ...
toString() getBonus() etc.
Two different views of the same object