A good answer might be:

Where in the above code is a constructor being used?

    HelloObject anObject = new HelloObject("A Greeting!"); 
                           ------------------------------

What is its parameter? A reference to the string "A Greeting!"

Constructor Definition Syntax

The class needs a constructor. Constructor definitions look like this:

className( parameterList )
{
  Statements usually using the variables of the 
  class and the parameters in the parameterList.
}

No return type is listed in front of className. There is no return statement in the body of the constructor. The constructor must have the same name as the class. The parameterList is a list of values and their types that will be handed to the constructor when it is asked to construct a new object. Parameter lists look like this (the same as parameter lists for methods):

TypeName1 parameterName1, TypeName2 parameterName2, ... as many as you need

It is OK to have an empty parameter list. A class often has several constructors with different parameters defined for it. Each one builds the same class of object, but will initialize it differently. A constructor returns a reference to the object it constructs. You do not use a return statement for this to happen. Usually the reference is saved in a variable. However, sometimes objects are constructed for temporary use and their reference is not saved. (They are used just once and then become garbage).

QUESTION 17:

Say that there is a class named DogHouse. Which of the following are OK as the first line of a constructor?

DogHouse( String dogName )

int DogHouse( String dogName )

void DogHouse( String dogName )

DogHouse( dogName )

DogHouse( String dogName );

DogHouse()
Click Here after you have answered the question