getBalance()
and processDeposit()
main()
Can't See Private Data
The main()
method was able to use the CheckingAccount
object
by using the object's access methods.
Here is a different main()
that does not use the access methods.
class CheckingAccount { private String accountNumber; private String accountHolder; private int balance; . . . . } class CheckingAccountTester { public static void main( String[] args ) { CheckingAccount bobsAccount = new CheckingAccount( "999", "Bob", 100 ); System.out.println( bobsAccount.balance ); bobsAccount.balance = bobsAccount.balance + 200; System.out.println( bobsAccount.balance ); } }
What happens when you compile this program?