Caffeinated Coder
Book an appointment
Lesson 09 · Objects

Inheritance and interfaces

A base class holds what related classes share; a derived class inherits it with a colon and overrides what must differ. An interface is a contract any class can sign. Follow one small program: Square and Rect inherit from the abstract class Shape, which implements IShape; the same line of code prints Square: 9 and then Rect: 10, because each call runs the override of the object's real type.

14 min10 steps5 questionsIntermediate
Fig 9 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.