Answer:

A complete program is below.

Completed Constructor

Here is a complete program. The constructor in the definition of HelloObject has a parameter named st. This parameter is used to pass data into the constructor. The constructor itself does nothing but copy it to the variable greeting of the object.

class HelloObject                                  
{
  String greeting;

  HelloObject( String st )
  {
    greeting = st;
  }

  void speak()                                     
  { 
    System.out.println( greeting );
  }
}

class HelloTester
{
  public static void main ( String[] args )        
  {
    HelloObject anObject = new HelloObject("A Greeting!"); 
    anObject.speak();
  }
}

QUESTION 20:

What will this program print on the monitor when it is run?