Concept · Intro

Objects & Classes

A class is a blueprint; an object is a concrete instance created from it, with its own state.

Asked atAmazonMicrosoftAdobe
step 1 / 5
Blueprint → instances
«new»«new»
Car
- brand: String
- speed: int
+ accelerate()
+ brake()
tesla : Car
brand = "Tesla"
speed = 0
mini : Car
brand = "Mini"
speed = 60
Blueprint → instances
1class Car {
2 String brand;
3 int speed;
4 void accelerate() { speed += 10; }
5}
6 
7Car tesla = new Car();
8Car mini = new Car();
State
classa blueprint, not an object

Start with the blueprint. The Car class defines the fields every car will hold (brand, speed) and the methods it can perform (accelerate, brake) — but it stores no actual values. It is a template, not a car.