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
Get Java For Everyone: Compatible with Java 5, 6, and 7, 2nd Edition 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.