Test Program

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:

  //constructors
  CheckingAccount( String accNumber, String holder, int start )
  {
    accountNumber = accNumber ;
    accountHolder = holder ;
    balance       = start ;
  }

Test Program

We have enough code to put together a test program. The test program will not do much, but it will compile and run.

class CheckingAccount
{
  // instance variables
  String accountNumber;
  String accountHolder;
  int    balance;

  //constructors
  CheckingAccount( String accNumber, String holder, int start )
  {
    accountNumber = accNumber ;
    accountHolder = holder ;
    balance       = start ;
  }

  // methods
}

class CheckingAccountTester
{
  public static void main( String[] args )
  {
    CheckingAccount account1 
            = new CheckingAccount( "123", "Bob", 100 );

    System.out.println( account1.accountNumber + " " +
        account1.accountHolder + " " + account1.balance );
  }
}

This program can be copied to a file, compiled, and run in the usual way. The output will be:

C:/chap32>java CheckingAccountTester

123 Bob 100

QUESTION 8:

What does the expression   account1.accountNumber   mean? (Look in the println statement to see where this expression was used.)