Topic 1.12 — Objects: Instances of Classes
Goal: explain what an object is, connect objects to classes, and understand that objects have state (data) and behavior (methods).
The big idea
A class is a blueprint. An object is a real “thing” created from that blueprint. Objects are called instances of a class.
In Java, you work with objects constantly (like String), because they bundle data + methods together.
Think like this
Objects have state + behavior
- State: information stored in the object (often called fields/instance variables).
- Behavior: actions the object can perform (methods you can call).
You don’t need to write your own fields yet in Unit 1—just recognize that objects “carry” data and methods together.
Example you already know: String
Each String object represents a sequence of characters. Different strings are different objects.
String a = "hello";
String b = "goodbye";
Both are String objects (same class), but they represent different values (different instances).
Class type vs. primitive type
Primitive types (not objects)
int,double,boolean,char
Store simple values directly (no methods attached).
Reference types (objects)
Stringand other classes
Variables store a reference to an object; objects come with methods.
What a variable holds (preview idea)
For primitives, the variable holds the value. For objects, the variable holds a reference to the object.
int x = 5; // x stores the value 5
String s = "hi"; // s refers to a String object
You’ll go deeper into this idea when you start creating objects and calling instance methods.
Common confusion
- A class is not an object. It’s the blueprint.
- An object is not a method. Methods belong to objects/classes.
- A variable of a class type is not the same thing as the object itself (it refers to it).
Exam mindset
- Be able to say: “An object is an instance of a class.”
- Recognize that objects group data + methods.
- Know that
Stringis an object type, butintis primitive. - When you see a class name as a type, you’re dealing with objects (reference types).
Quick self-check
- What is the difference between a class and an object?
- What are “state” and “behavior” for an object?
- Is
intan object? IsStringan object type? - What does “instance of a class” mean?
- Why is it useful that objects bundle data + methods?