Difference Between Overloading And Overriding With Examples

Difference between Overloading and Overriding With Examples







Difference between Overloading and Overriding


 
 
 
 
 
 
 
 

No
Overloading
Overriding
1
Relationship between methods available in the same class.
Relationship between a super class method and a subclass method.
2
Does not block inheritance from the super class.
Blocks inheritance from the super class.
3
Separate methods share (overload) the same name.
Subclass method replaces (overrides) the super class method.
4
Different method signatures.
Same method signatures.
5
May have different return types.
Must have matching return types.
6
May have different declared exceptions.
Must have compatible declared exceptions.

Labels: