go to previous page   go to home page   go to next page

Answer:

Any type of data at all:

We have not used arrays of object references so far in these notes. They will be discussed in a future chapter.

Review Program

Here is a short program: Here is a description of the action:
// Review Program
//
class Alteration
{
  void zero ( int x )
  {
    x = 0;
  }
}

class AlterTest
{
  public static void main ( String[] args )
  {
    Alteration alt = new Alteration();
    int value = 27;
    System.out.println( "Before:" + value );
    
    alt.zero( value );
    System.out.println( "After:"  + value );
  }
}
  1. The program starts running with the static main() method.
  2. An Alteration object is constructed.
    • The default constructor is used, since the class Alteration does not define a constructor.
    • The Alteration object contains the zero() method.
  3. The primitive int variable value is initialized to 27.
  4. The number currently held in value is printed out.
    • Before: 27 is printed
  5. The zero() method is called with value as a parameter.
    • Think about what happens next. It is easy to make a mistake here.
  6. The number currently held in value is printed out.
    • What is printed out?

QUESTION 2:

What is printed out?