Overloading vs Overriding

Posted September 9, 2022 by Rohith and Anusha ‐ 1 min read

When two or more methods in the same class have the same name but different parameters, it's called Overloading. When the method signature (name and parameters) are the same in the superclass and the child class, it's called Overriding.

A list of differences between method overloading and method overriding are stated below

Method OverloadingMethod Overriding
Method overloading is used to increase the readability of the program.Method overriding is used to provide the specific implementation of the method that is already provided by its super class.
Method overloading is performed within class.Method overriding occurs in two classes that have IS-A (inheritance) relationship.
In case of method overloading, parameter must be different.In case of method overriding, parameter must be same.
Method overloading is the example of compile time polymorphism.Method overriding is the example of run time polymorphism.
In java, method overloading can’t be performed by changing return type of the method only. Return type can be same or different in method overloading. But you must have to change the parameter.Return type must be same or covariant in method overriding.
quick-references blog overriding overloading differences

Subscribe For More Content