What is the difference between method overloading and method overriding? Which one is decided at run time?
Show the explanation
Model answer. Overloading: several methods in the same class share a name but differ in parameter list (number or types); the compiler chooses one from the argument types — compile-time (static) polymorphism. Overriding: a subclass provides its own implementation of a method with the same signature as in the parent; the version called depends on the object's actual class — run-time (dynamic) polymorphism via dynamic dispatch.
Example: Shape s = new Circle(); s.area(); calls Circle.area() even though the variable type is Shape. In Java, static, private and final methods cannot be overridden; changing only the return type is not overloading.
Original UniCircle question. Last reviewed 21 Oct 2026.
