Does this method have a parameter list?

A good answer might be:

No. However, the empty pair of parentheses ( ) are required, even if there is no parameter list.

Parameter Lists

class HelloObject
{
  // method definition
  void speak()
  {
    System.out.println("Hello from an object!");
  }
}

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

A parameter list is a list of values that will be handed to the method (or constructor) when the method (or constructor) is called. They will be discussed further in another chapter.

This is a good program to copy to Notepad to and run. Save the file as HelloTester.java because the file name must match the name of the class that contains the main() method. When you run this program it will write this out:

Hello from an object!
The details of how this happens will be discussed next.


QUESTION 9:

Examine the program.

  1. How many class definitions are there in this program?
  2. How many objects are created when the program runs?

Click Here after you have answered the question