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

Answer:

123     Bob     100
456     Jill    900
123     Bob     100

Review of ==

The == (equal-equal) operator is an alias detector. It checks if two reference variables refer to the same object. It does not actually look at the objects. The following program segment illustrates this:

  {
    CheckingAccount account1 = new CheckingAccount( "123", "Bob", 100 );
    CheckingAccount account2 = new CheckingAccount( "456", "Jill", 900 );
    CheckingAccount account3; 
    
    account3 = account1;
    if ( account1 == account 3 )
       System.out.println("An alias has been detected!");
    else
       System.out.println("These are different objects!");
   
  }

It will print out An alias has been detected!.

QUESTION 22:

Say that the following lines are added to the program (immediately following the lines already there):

    account3.processCheck( 85 );  // subtract 100 cents, including service charge
    account1.display();
    account3.display();

What will be printed?