class CheckingAccount { private String accountNumber; private String accountHolder; private int balance; private int useCount = 0; public CheckingAccount( String accNumber, String holder, int start ) { . . . . } private void incrementUse() { . . . . } public int getBalance() { . . . . } public void processDeposit( int amount ) { . . . . } public void processCheck( int amount ) { . . . . } public void display() { . . . . } }
If you do not specify public
or private
for
a variable or a method,
then it will have default
visibility.
Default visibility allows a variable or method to
be seen by all methods of a class or other classes that
are part of the same package.
A package is a group of related classes.
For now, default
visibility means
about the same thing as public
visibility.
But it is best to explicitly declare members public
if that is what you actually need.
You can not explicitly declare a member of a class to have
default
visibility
(for example, you can't say default int monthlyCharge;
)
Later on,
after these notes have discussed inheritance there
will be other visibility modifiers,
and additional rules for public
and private
visibility.
Should a constructor be made public
or private
?