Caffeinated Coder
Book an appointment
Lesson 06 · Objects

Classes and objects

A class is a blueprint and a type: it lists the fields every object has and the methods that work on them. Follow a small bank account through memory: new makes an object on the heap with its fields at their defaults, the constructor gives it a valid start, and the variable keeps only a reference. Copy that variable and you copy the reference, so two names share one object, and the program prints 75.

12 min10 steps5 questionsIntermediate
Fig 6 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.