Difference between method overloading and method overriding

Parameter Method Overloading Method Overridding
1)Defination When a class having more than methods with same name but change in signature then method is said to be overloaded. Method overriding means providing subclass specific implementation for the inherited method.
2)Signature Signature should be different.Method signature means Number of parameter should be different, Order of parameter should be different, Sequence of parameter should be different. Signature Should be same.
3)Return type Return type of overloaded method may or may not be same. Return type of overridded method should be same
4)Access modifier Access modifer of overloaded methods can be anything Access modifier of overrided method must be same or higher visibility
5)Polymorphism Method overloading is called as Compile time polymorphism Method overridding is called as Run time polymorphism
6)Scope Method overloading is performed within a class Method overridding is perform between two classes or between interface and class through inheritance
7)Contructor Contructor can be overloaded Contructor can not be override because we can not inheritate the contructor.
8)Private Method Private method can be overloaded Private method can not be override
9)Static Method Static method can be overloaded Static method can not be override
10)final Method final method can be overloaded final method can not be override
11)abstract method abstract method can be overloaded abstract method can be override

Example:

Method overloading Example:

method overloading example

Method overridding Example:

method overridding example

You may also like...

Leave a Reply