The creator of a Java class controls what access objects
outside the class have to the implementation (the inner
details) of objects of her class by giving variables and methods
accessability qualifiers.
public
All outside objects can call public methods.
Any outside object can potentially change public variables.
private
methods are only callable within the
instance methods of the class - not by subclasses.
variables are only accessable within the
methods of the class - not from subclasses.
protected
methods are only callable from the methods of the class and any
sub classes.
variables are accessable within the instance methods of the class
and any sub classes.
"Package access" - the default if not otherwise specified:
Instances of any class in the same package may
call methods with package access.
Instances of any
class in the same package can access package variables
Question:Why add an accessability qualifier to a method or variable?