 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
What
is the meaning in Java of public, private, and protected?
|
|
| • |
As
is expected, public means that the member following is
|
|
|
public
to everyone using this library
|
|
| • |
Private
is not available – only other methods within the class
|
|
|
can
access that member
|
|
|
– |
Helper
methods should be private
|
|
|
| • |
Protected
members are available within this class and a derived
|
|
class
(same as C++)
|
|
| • |
Recommendation:
limit your use of the default friendly access
|
|
|
– |
(Please
note, a derived class may not be able to access its parent’s
|
|
|
“friendly”
members if they are not in the same package! This is because
|
|
|
it is
possible to inherit from a class that is not in the same package.)
|
|