QuickDevGuide

Home › OOPs

Overloading vs Overriding — OOPs

Both are forms of polymorphism, but they work at different times. Overloading Overriding Kind Compile-time (static) polymorphism Runtime (dynamic) polymorphism Where Same class Subclass redefines parent method Signature Same name, different parameters Same name and parameters Return type Can differ Same or covariant (subtype) Decided by Declared argument types Actual object type at runtime Keywords — Java @Override, C# virtual/override, TS override Rules for overriding The method cannot be more restrictive (a public method cannot become private). It cannot throw broader checked exceptions (Java). static, private and final methods cannot be overridden (static methods are hidden). Language notes Python and JavaScript do not support overloading by signature — the last definition wins. Use…

Key Takeaways