Difference between method overloading and method overriding in java ?

Method Overloading VS Method Overriding
Sr.Method OverloadingMethod Overriding
1Method Overloading occurs within the same classMethod Overriding occurs between two classes superclass and subclass
2Since it involves with only one class inheritance is not involved.Since method overriding occurs between superclass and subclass inheritance is involved.
3In overloading return type need not be the sameIn overriding return type must be same.
4Parameters must be different when we do overloadingParameters must be same
5Static polymorphism can be achieved using method overloadingDynamic polymorphism can be achieved using method overriding.
6In overloading one method canโ€™t hide the anotherIn overloading one method canโ€™t hide the another
Overloading Vs Overriding

Posted

in

Tags:

Comments

Leave a Reply