CHAPTER 8
OBJECTS AND CLASSES 
CHAPTER GOALS
To understand the concepts of classes, objects, and encapsulation
To implement instance variables, methods, and constructors
To be able to design, implement, and test your own classes
To understand the behavior of object references, static variables, and static methods
CHAPTER CONTENTS
8.1 OBJECT-ORIENTED PROGRAMMING
8.2 IMPLEMENTING A SIMPLE CLASS
Syntax 8.1: Instance Variable Declaration
8.3 SPECIFYING THE PUBLIC INTERFACE OF A CLASS
Special Topic 8.1: The javadoc Utility
8.4 DESIGNING THE DATA REPRESENTATION
8.5 IMPLEMENTING INSTANCE METHODS
Programming Tip 8.1: All Instance Variables should Be Private; Most Methods should Be Public
Common Error 8.1: Forgetting to Initialize Object References in a Constructor
Common Error 8.2: Trying to Call a Constructor
Common Error 8.3: Declaring a Constructor as void
Special Topic 8.2: Overloading
How To 8.1: Implementing a Class
Worked Example 8.1: Implementing a bank Account Class ![]()
Video Example 8.1: Paying Off a loan ![]()
8.8 PROBLEM SOLVING: TRACING OBJECTS
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access