Interfaces
Contracts specifying methods that implementing classes must provide without defining implementation. Interfaces define capabilities without forcing implementation details. Classes can implement multiple interfaces, enabling flexible composition. This pattern enables polymorphism without inheritance hierarchies.
Real World
Spotify's music player implements both a Playable interface and a Downloadable interface, allowing the same Track class to support streaming and offline playback without needing a complex inheritance tree.
Exam Focus
Contrast interfaces with abstract classes by emphasising that a class can implement multiple interfaces but inherit only one class.
How well did you know this?