January 2014
Intermediate to advanced
736 pages
70h 43m
English
The access modifiers public and private control access to a class’s variables and methods. In Appendix G, we’ll introduce the access modifier protected. As you know, the primary purpose of public methods is to present to the class’s clients a view of the services the class provides (the class’s public interface). Clients need not be concerned with how the class accomplishes its tasks. For this reason, the class’s private variables and private methods (i.e., its implementation details) are not accessible to its clients.
Figure F.3 demonstrates that private class members are not accessible outside the class. Lines 9–11 attempt to access directly the private instance variables hour, minute and second of the
Read now
Unlock full access