Property
|
Overloading
|
Overriding
|
Method
name
|
Must be
same
|
Must be
same
|
Method
argument
|
Must be
different (at least order)
|
Must be
same (including order)
|
Method
signature
|
Must be
different
|
Must be
same
|
Return
type
|
No
restrictions
|
Must be
same until 1.4 version, but from 1.5v onwards co-variant return types are
also allowed.
|
Private,
static, final methods
|
Can be
overloaded
|
Can’t be
overloaded
|
Access
modifiers
|
No
restrictions
|
We can’t
reduce the scope but we can increase
|
Throws
classes
|
No restrictions
|
If child
class throws any checked exception compulsorily parent class method should
throw the same checked exception or its parent; but there is no restriction
for unchecked exception.
|
Method
resolution
|
Always
taken care by compiler based on reference type.
|
Always
taken care by jvm based on runtime object.
|
Also known
as
|
Static
polymorphism or compile time polymorphism or early binding
|
Dynamic
polymorphism or runtime polymorphism or late binding
|
Wednesday, 1 February 2017
DIFFERENCE BETWEEN OVERLOADING AND OVERRIDING IN JAVA
Labels:
JAVA
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment