13.2 Starting to Program the Classes of the ATM System
[Note: This section can be taught after Chapter 8.]
Visibility
We now apply access modifiers to the members of our classes. We’ve introduced access modifiers public
and private
. Access modifiers determine the visibility or accessibility of an object’s attributes and methods to other objects. Before we can begin implementing our design, we must consider which attributes and methods of our classes should be public
and which should be private
.
We’ve observed that attributes normally should be private
and that methods invoked by clients of a given class should be public
. Methods that are called as “utility methods” only by other methods of the same class normally should be private
. The ...
Get Java How to Program (early objects), 9/e now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.