Example main()

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page

Answer:

The number of times each individual object has been used. (If this is not clear, look at the class definition again to see that the variable useCount is part of each object, and that each object has its own method incrementUse() which increments its own variable.)

Example main()

Here is a main() that shows these ideas:

class CheckingAccountTester
{
  public static void main( String[] args )
  {
    CheckingAccount bobsAccount  = new CheckingAccount( "999", "Bob", 100 );
    CheckingAccount jillsAccount = new CheckingAccount( "111", "Jill", 500 );

    bobsAccount.processCheck( 50 );
    System.out.println( bobsAccount.toString() );

    jillsAccount.processDeposit( 500 );
    jillsAccount.processCheck( 100 );
    jillsAccount.processCheck( 100 );
    jillsAccount.processDeposit( 100 );

    System.out.println( jillsAccount.toString() );
  }
}

QUESTION 14:

How may times has Bob's account been used?

How may times has Jill's account been used?