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

Answer:

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.

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()
  {
    super.greeting();
    System.out.println("How you have grown!!\n");
  }
}

QUESTION 8:

What will be written by the following:

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