Include:

Class Info
Grade Level
Other Information
Custom Fields
Public Notes
Reflection
Date(s)
Multiple Days
Structure
Purpose
Minutes
Common Core Standards
Reading and Writing

Classes and Objects

Grade Level:
12
Subject:
AP Computer Science
Topic:
Classes and Objects
Objective:
OBJECTS
Every program that you write involves at least one thing that is being created or manipulated by the program. This thing, together with the operations that manipulate it,
is called an object.
Consider, for example, a program that must test the validity of a four-digit code
number that a person will enter to be able to use a photocopy machine. Rules for
validity are provided. The object is a four-digit code number. Some of the operations
to manipulate the object could be readNumber, getSeparateDigits, testValidity,
and writeNumber.
Any given program can have several different types of objects. For example, a program that maintains a database of all books in a library has at least two objects:
1. A Book object, with operations like getTitle, isOnShelf, isFiction, and
goOutOfPrint.
2. A ListOfBooks object, with operations like search, addBook, removeBook, and
sortByAuthor.
An object is characterized by its state and behavior. For example, a book has a state
described by its title, author, whether it’s on the shelf, and so on. It also has behavior,
like going out of print.
Notice that an object is an idea, separate from the concrete details of a programming
language. It corresponds to some real-world object that is being represented by the
program.
All object-oriented programming languages have a way to represent an object as a
variable in a program. In Java, a variable that represents an object is called an object
reference.
14
Prep:
None entered.
Materials:
None entered.