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

Class Blueprint / type
Describes what objects of that type look like and what they can do.
Object Instance / actual value
A specific “member” of the class with its own data.

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)

  • String and 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 String is an object type, but int is primitive.
  • When you see a class name as a type, you’re dealing with objects (reference types).

Quick self-check

  1. What is the difference between a class and an object?
  2. What are “state” and “behavior” for an object?
  3. Is int an object? Is String an object type?
  4. What does “instance of a class” mean?
  5. Why is it useful that objects bundle data + methods?

← Back to Unit 1 topics