Difference Between Overloading and
Overriding in Java
Feature Overloading Overriding
Definition Defining multiple methods Redefining a method in a
with the same name but subclass that is already
different parameter lists defined in the superclass.
(method signatures).
Occurs In Same class or subclass. Subclass (requires
inheritance).
Method Signature Same method name but Same method name, same
different parameters parameters, and same
(number, type, or order). return type.
Return Type Can have the same or Must have the same return
different return types. type as the overridden
method.
Polymorphism Type Compile-time Runtime polymorphism
polymorphism (early (late binding).
binding).
Access Modifiers No restrictions on access Overriding method cannot
modifiers. reduce visibility (e.g., public
cannot be overridden with
protected).
Static/Instance Methods Can overload both static Can only override instance
and instance methods. methods (static methods
cannot be overridden).
Binding Static binding (resolved at Dynamic binding (resolved
compile time). at runtime).
Inheritance Inheritance is not required Inheritance is required
(can occur in the same (method must be inherited
class). from the superclass).
Use Case Allows methods with the Allows a subclass to modify
same name to handle the behavior of an inherited
different types or numbers method.
of inputs.
Keywords Restrictions No restrictions related to Cannot override methods
final, static, or private. marked final, static, or
private in the superclass.
Throws Clause (Exceptions) Overloaded methods can Overriding methods can
throw different exceptions only throw the same or a
or none at all. more specific exception.
Annotation No specific annotation @Override annotation is
required. optional but recommended.
Constructor Constructors can be Constructors cannot be
overloaded. overridden (since they are
not inherited).
Return Type Covariance Not applicable (return types Covariant return type
can differ). allowed (return type can be
a subclass of the original).