Difference between overriding and overloading in java?
In overriding method names must be same In overloading method names must be same
Argument List must be same Argument list must be different atleast order of
Return type can be same or we can return covariant
type. From 1.5 covariant types are allowed
Return type can be different in overloading.
We cant increase the level of checked exceptions.
No restrictions for unchecked exceptions
In overloading different exceptions can be thrown.
A method can only be overridden in subclass A method can be overloaded in same class or
Private,static and final variables cannot be
Private , static and final variables can be
In overriding which method is called is decided at
runtime based on the type of object referenced at
In overloading which method to call is decided at
compile time based on reference type.
Overriding is also known as Runtime polymorphism,
dynamic polymorphism or late binding
Overloading is also known as Compile time
polymorphism, static polymorphism or early