private void incrementUse() { useCount = useCount + 1; }
main() Can't use a Private Method
Here is a main() that mistakenly tries to
change useCount:
class CheckingAccount
{
private String accountNumber;
private String accountHolder;
private int balance;
private int useCount = 0;
. . . .
private void incrementUse()
. . . .
}
public class CheckingAccountTester
{
public static void main( String[] args )
{
CheckingAccount bobsAccount = new CheckingAccount( "999", "Bob", 100 );
bobsAccount.processCheck( 50 );
bobsAccount.incrementUse();
bobsAccount.useCount = 15;
}
}
Will this program compile and execute?