The blanks are filled in, below:
super()
Invoke the superclass constructor
by using super.
In a constructor, super
must appear before anything else
(although in this example there isn't anything else.)
Recall that even if you don't put it in explicitly the
compiler will automatically put a call to super
as
the first thing a constructor does.
class YouthBirthday extends Birthday { public YouthBirthday ( String r, int years ) { super ( r, years ) } public void greeting() { super.greeting(); System.out.println("How you have grown!!\n"); } }
When the greeting()
method of a YouthBirthday
object is invoked,
first its superclass's method will run, then the rest of the new method will run.
What will be written by the following:
YouthBirthday yb = new YouthBirthday( "Valerie", 7 ); yb.greeting();