Object

In AP Computer Science A, an object is an instance of a class, created with the new keyword, that bundles its own data (instance variables) with behavior (methods). The class is the blueprint; the object is the actual thing built from it that lives in memory while your program runs.

Verified for the 2027 AP Computer Science A examLast updated June 2026

What is the Object?

An object is a specific instance of a class. The class is the blueprint, and the object is the actual house built from it. Each object gets its own copy of the class's instance variables, so two Dog objects can have different names and ages even though they came from the same class. Objects also carry behavior, meaning you can call methods on them (like myDog.bark()) and the method runs using that particular object's data.

In Java, you create an object by calling a constructor with the new keyword, like Dog d = new Dog("Rex", 3);. One subtle but huge detail for the AP exam is that the variable d doesn't hold the object itself. It holds a reference to the object, basically the object's address in memory. That's why two variables can point to the same object, and why changing the object through one variable shows up when you look at it through the other.

Why the Object matters in AP Computer Science A

Objects are the spine of the entire AP CSA course, which is why the exam is built around object-oriented programming. You first learn to use objects (calling constructors and methods on classes someone else wrote), then to write your own classes that produce objects with instance variables, constructors, and methods. Later, inheritance and polymorphism are entirely about the relationship between an object's actual type and the type of the reference variable pointing at it. If you don't have a solid mental model of what an object is, almost every FRQ becomes harder than it needs to be, because every FRQ either uses objects or asks you to design a class that creates them.

How the Object connects across the course

Class (Units 2 & 5)

A class and an object are two halves of the same idea. The class is the cookie cutter; objects are the cookies. You can stamp out as many objects as you want from one class, and each one keeps its own data.

Constructor & New Keyword (Unit 2)

Objects don't just appear. The new keyword calls a constructor, the constructor initializes the instance variables, and out comes a fresh object. If a class has overloaded constructors, you pick which one to call by the arguments you pass.

Instance Variable (Unit 5)

Instance variables are the per-object data. Every object created from a class gets its own copies, which is exactly why dog1.name and dog2.name can be different. When you write a class on the FRQ, choosing the right instance variables is choosing what each object remembers.

Inheritance & Polymorphism (Unit 9)

Here the exam splits hairs between an object's actual type and its reference type. A Poodle object can sit behind an Animal reference because a Poodle is-a Animal, but casting that reference back down only works if the object really is a Poodle. Get this wrong and you get a ClassCastException at runtime.

Is the Object on the AP Computer Science A exam?

Objects show up everywhere, so the exam tests whether you understand them at three levels. MCQs love reference behavior, like which declarations are legal in an inheritance hierarchy (can an Animal variable hold a Poodle object?) and which casts cause a ClassCastException at runtime. They also test polymorphism, where the object's actual type decides which overridden method runs, as in a Shape reference pointing to a Circle object. On the FRQ side, you're constantly creating and using objects. The 2017 exam alone had Q1 (Digits) asking you to build an object that stores a number's digits in an ArrayList, Q2 asking you to design a full class implementing the StudyPractice interface, and Q3 (Phrase) asking you to write methods that operate on an object's instance variable. Expect to write constructors that initialize instance variables, call methods on objects, and reason about what happens when multiple references point to the same object.

The Object vs Class

A class is the blueprint; an object is the thing built from it. The class exists once in your code and defines what instance variables and methods every object will have. Objects exist at runtime, possibly in the thousands, each with its own data. You write public class Dog {...} exactly once, but new Dog(...) can run as many times as you want, and each call makes a separate object.

Key things to remember about the Object

  • An object is an instance of a class, created at runtime with the new keyword, and each object gets its own copies of the instance variables.

  • Variables in Java hold references to objects, not the objects themselves, so two variables can point to the same object and see each other's changes.

  • Calling a constructor with new is the only way to create an object, and the constructor's job is to initialize that object's instance variables.

  • With inheritance, a superclass reference can point to a subclass object (an Animal variable can hold a Dog object), but never the reverse.

  • When a method is overridden, the object's actual type, not the reference type, decides which version of the method runs at runtime.

  • Every AP CSA FRQ involves objects in some way, whether you're writing a class that creates them or writing methods that use them.

Frequently asked questions about the Object

What is an object in AP Computer Science A?

An object is an instance of a class that bundles data (instance variables) and behavior (methods) together. You create one with the new keyword, like Dog d = new Dog("Rex", 3);, and each object keeps its own copies of the instance variables.

Is an object the same thing as a class?

No. The class is the blueprint written once in your code, and objects are the actual things built from it at runtime. One class can produce unlimited objects, each with different data.

What's the difference between an object and a reference variable?

The object is the actual data living in memory, while the variable holds a reference (the object's address). That's why Dog a = b; doesn't copy the dog, it just makes two variables point to the same object, and a change through one shows up in the other.

Can a superclass variable hold a subclass object?

Yes. Animal a = new Poodle(); is legal because a Poodle is-a Animal, and this is the basis of polymorphism. The reverse, like Poodle p = new Animal();, won't compile, and a bad downcast like casting a plain Student object to GradStudent throws a ClassCastException at runtime.

How do objects show up on the AP CSA free-response questions?

Every FRQ involves objects. FRQ 2 is always class design, where you write a full class with instance variables, a constructor, and methods (like the 2017 StudyPractice question), and the other FRQs have you write methods that use or modify an object's data, like 2017's Digits and Phrase questions.