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


The blanks are filled in, below:


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.

In the greeting() method of YouthBirthday, first the superclass's method is invoked, then the additional code runs. In a method, super does not have to come first, although in this method that is where it makes sense.

class YouthBirthday  extends  Birthday

  public  YouthBirthday ( String r, int years )
    super ( r, years );

  public void greeting()
    System.out.println("How you have grown!!\n");


What will be written by the following:

YouthBirthday yb = new YouthBirthday( "Sophia", 7 );