
Define instance variables of
a class as private so that
only methods of the class
will be able to set or
change their values.
SOFTWARE
ENGINEERING TIP
374 CHAPTER 7 Object-Oriented Programming,Part 2: User-Defined Classes
class or member can be accessed by methods in classes that are in the same
package. Later in the chapter, we will learn how to create our own package.
We’ll defer discussing the protected access modifier until Chapter 10, where we
cover inheritance.
Typically, the accessModifier for a class will be public, and we know that a public
class must be stored in a file named ClassName.java where ClassName is the
name of the class. Not all classes ...