Differentiate between method overloading and method overriding.
Sr. No.
|
Method overloading
|
Method overriding
|
1 |
Overloading occurs when two or more methods in one class have the same method name but different parameters.
|
Overriding means having two methods with the same method name and parameters (i.e., method signature)
|
2 |
In contrast, reference type determines which overloaded method will be used at compile time.
|
The real object type in the run-time, not the reference variable's type, determines which overridden method is used at runtime
|
3 |
Polymorphism not applies to overloading
|
Polymorphism applies to overriding
|
4 |
overloading is a compiletime concept.
|
Overriding is a run-time concept
|