Beginner 20 min read

What Is a Class?

By the end of this lesson, you'll be able to:

  • Define what a class is: a blueprint for creating objects
  • Distinguish between a class definition and an instance of that class
  • Recognize that every Apex file you've written so far has actually been inside a class

Prerequisites: Module 9: "Methods: Reusable Instructions"

A blueprint, not the thing itself

public class GymMember {
    public String name;
    public Integer age;
}

GymMember doesn't represent any specific member — it's a template describing what data every gym member has: a name and an age. No actual member exists yet; this is just the shape.

A real-world analogy: architectural blueprints

An architect's blueprint for a house describes where the walls, doors, and windows go — but a blueprint is not a house you can live in. Many actual houses can be built from the same blueprint, each standing separately. A class works the same way: one blueprint, many actual objects built from it.

You've been inside a class all along

Every System.debug and every method from Modules 1-9 has technically lived inside a class already — the seeder and lesson code you've been reading is itself organized into classes. This module makes that structure explicit and puts it in your hands.

Exercise

As a comment, explain the difference between a class and an object in your own words.

Show hint

A class is the blueprint; an object is one specific thing built from it.

APEX

What Is a Class? Quiz

1. What is a class?

Log in to submit the quiz and save your score.

My Notes

Log in to keep private notes on this lesson.

Questions about this lesson

No questions yet — be the first to ask.

Log in to ask a question about this lesson.

Summary

A class is a blueprint that describes what data and behavior a certain kind of "thing" has — every object you create in Apex is built from a class.