Back to Using Objects

Lesson PreviewLesson 1 of 10 in this unit

2.1 Objects: Instances of Classes

Part of Using Objects in AP® Computer Science A. Read the opening section, then create a free account for the full interactive lesson, practice, and progress tracking.

Lesson

What is a " class " in Java?

Think of a class as a blueprint or instruction sheet. This blueprint can help you create objects, while you, the programmer, get to decide the more specific properties of those objects.

For example, you can have a class named "Car," which shows the computer how to make a car. The class will tell the computer that the car should have a color, a year, and a name. The class can also tell the computer what the car can do. For example, our car can honk and drive.

Let’s try to make our Car class in Java! To create a class, use the Java keywords public and class before your class’s name. Also, make sure to add curly brackets afterward.

java
public class Car {}

Continue the full lesson in Stellar

Create a free account to unlock the remaining sections, checkpoints, course practice, and progress tracking for AP® Computer Science A.