Sr. | Method Overloading | Method Overriding |
1 | Method Overloading occurs within the same class | Method Overriding occurs between two classes superclass and subclass |
2 | Since it involves with only one class inheritance is not involved. | Since method overriding occurs between superclass and subclass inheritance is involved. |
3 | In overloading return type need not be the same | In overriding return type must be same. |
4 | Parameters must be different when we do overloading | Parameters must be same |
5 | Static polymorphism can be achieved using method overloading | Dynamic polymorphism can be achieved using method overriding. |
6 | In overloading one method canโt hide the another | In overloading one method canโt hide the another |
Leave a Reply