A good answer might be:DogHouse( String dogName ) // OK int DogHouse( String dogName ) // NOT OK void DogHouse( String dogName ) // NOT OK DogHouse( dogName ) // NOT OK (Need a type name in the parameter list) DogHouse( String dogName ); // NOT OK DogHouse() // OK (It is OK to omit the parameter list). |
Coding a ConstructorHere is HelloObject with an incomplete constructor added:
The parameter list of the constructor is this: This says that the constructor will be handed a reference to a String when it is used (when it is called.) The name of the parameter is st. In the body of the constructor, st is used to represent the data. The constructor will initialize the variable greeting with data that is supplied when the constructor is used. For example, in the main() method above the String "A Greeting!" is supplied as data to the constructor.String st |
QUESTION 18:Fill in the blank so that the constructor is complete. Click Here after you have answered the question |