super()

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.

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.

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.

QUESTION 8:

What will be written by the following:

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