OOP: Classes, Inheritance and Polymorphism
Harry
· 16 Sep 2026
· 11 views
Log in to track your progress and mark lessons complete.
Sponsored
The four pillars
OOP is the heart of the exam. Master the four pillars:
Overriding vs overloading
- Overriding – a subclass redefines a superclass method with the same signature. Resolved at runtime (dynamic dispatch).
- Overloading – same method name, different parameters, in the same class. Resolved at compile time.
class Animal { String sound() { return "..."; } }
class Dog extends Animal {
@Override String sound() { return "Woof"; }
}
Animal a = new Dog();
System.out.println(a.sound()); // "Woof" - runtime type wins
Abstract classes and interfaces
An abstract class can have state and partial implementation; a class extends one. An interface is a contract; a class can implement many, and interfaces can have default methods. Know when each applies – a favourite exam theme.
Key points
- Know encapsulation, inheritance, polymorphism and abstraction cold.
- Overriding is runtime (same signature); overloading is compile-time (different params).
- A class extends one abstract class but implements many interfaces.
- Polymorphism: the object's runtime type decides which override runs.