February 2014
Beginner
1248 pages
62h 25m
English
The access modifiers public and private control access to a class’s variables and methods. In Chapter 9, we’ll introduce the additional access modifier protected. The primary purpose of public methods is to present to the class’s clients a view of the services the class provides (i.e., 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 8.3 demonstrates that private class members are not accessible outside the class. Lines 9–11 attempt to access the private instance variables hour, minute and second of the Time1 object ...
Read now
Unlock full access