Java Interview Common Basic Question

Dark Angel
1 min readMar 20, 2022

Overloading vs Overriding

Overloading : If a class have multiple methods by same name but different parameters, it is known as Method Overloading.

Overriding : If subclass provides the specific implementation of the method that has been provided by one of its parent class, it is known as method overriding.

The differences between Overloading and Overriding:

a) 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.

b) Method overloading is performed within class.

Method overriding occurs in two classes that have IS-A (inheritance) relationship.

c) In case of method overloading, parameter must be different.

In case of method overriding, parameter must be same.

d) Method overloading is the example of compile time polymorphism.

Method overriding is the example of run time polymorphism.

e) 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.

--

--