Uploaded by Ahad Khan

Difference between Method Overloading and Method Overriding in java - javatpoint

advertisement
Difference between method overloading and
method overriding in java
There are many differences between method overloading and method overriding in
java. A list of differences between method overloading and method overriding are given
below:
No.
1)
Method Overloading
Method Overriding
Method overloading is used to increase the
Method overriding is used
readability of the program.
to provide the specific
implementation of the
method that is already
provided by its super class.
2)
Method overloading is performed within class.
Method overriding occurs in
two classes that have IS-A
(inheritance) relationship.
3)
In case of method overloading, parameter
In case of method
must be different.
overriding, parameter must
be same.
4)
Method overloading is the example of compile
Method overriding is the
time polymorphism.
example of run time
polymorphism.
5)
In java, method overloading can't be
Return type must be same
performed by changing return type of the
or covariant in method
method only. Return type can be same or
overriding.
different in method overloading. But you must
have to change the parameter.
Download