Tuesday, 17 March 2015

Q 06) Over Riding VS Over Loading




OverRiding/  Dynamic Binding/
Runtime polymorphism
OverLoading/ Static Binding/
Compile Time Polymorphism
01)
Over – Riding happens at RUN – TIME
I,e The binding of over-riding  method call to its definition happens at Runtime.
Over – Loading  happens at COMPILE – TIME.

I,e The binding of over-loading method call to its definition happens at Compile time.
02)
Static methods cannot be over - ridden, even if you declare static method in the child class, It has nothing to do with the same method of parent.
Static methods can be over -  loaded, Which means a class can have more than one static method of same name.
03)
Over – riding requires two classes a Base and a child class.
Over – loading is done in the same class.
04)
Dynamic Binding is used for Over - ridden/ Over-riding methods.
Static Binding is used for Over- loading  methods.



OverRiding/  DynamicBinding/
Runtime polymorphism
OverLoading/Static Binding/
Compile Time Polymorphism
05)
PERFORMANCE :
         Over – Riding is slow compared to
Over  - loading, because the binding of Over – riding methods are done at
run – time.
PERFORMANCE :
         Over – loading is better and faster compared to Over-riding.
06)
Private final methods cannot be Over – ridden.
Private final methods can be Over – Loaded.
07)
Return Type of Over – riding methods can be different from Over-ridden methods.
Return Type of Over – loading should be same for all methods.
08)
Argument – List should be same in Over – riding
Argument – List should be different while Over – loading.

No comments:

Post a Comment