Object-oriented programming mirrors the real world: classes describe things, objects are the things themselves.
1 Why OOP?
Real problems are full of things — cars, users, accounts. Classes let your code mirror them.
2 class = blueprint
A class declares fields (data) and methods (behavior). It holds no live data itself.
3 object = real thing
new builds an instance that owns its own copy of every field.
4 The big four ideas
Encapsulation, inheritance, polymorphism, abstraction — this course visits them one by one.
Blueprints and living objects
Why OOP?1Real problems are full of things — cars, users, accounts. Classes let your code mirror them.
class = blueprint2A class declares fields (data) and methods (behavior). It holds no live data itself. object = real thing3new builds an instance that owns its own copy of every field. The big four ideas4Encapsulation, inheritance, polymorphism, abstraction — this course visits them one by one. 4 building blocks make up Blueprints and living objects
Press Run to follow one object from blueprint to a living thing with its own data.
Press play: new builds the Pet, the constructor names it, and bark() speaks with its own data.
JVMThe JVM loads the file — PetApp runs the show; Pet is the blueprint.
Memory
no variables yet — press play
Console
output appears as the program runs…
Each new Pet builds an independent object — the blueprint is used twice, the objects never share fields.
process decision input / output start / end Click a term, then click its description to lock the pair.
5 conceptsTap a card to expand ?classdrops into place
?objectdrops into place
?fielddrops into place
?constructordrops into place
?referencedrops into place
01A class is a blueprint; objects are the things built from it.
02new creates the object on the heap and runs the constructor.
03Each object owns its fields — Rex never changes what Mia knows.
04A variable of object type holds a reference, not the object itself.
05OOP organizes code like the world: things with state and behavior.