filmov
tv
#6.5 Java Tutorial | Dynamic Method Dispatch

Показать описание
In this lecture we are discussing:
1)Loose coupling (Dynamic method dispatch)
2)compile time polymorphism vs runtime polymorphism
3)Benefits of Dynamic method dispatch
#1
loose coupling - using parents type reference and child type object.
Suppose we have three Class A,B and C here B and C are child of A.
in A there are show() method and both class B and c override show() method.
class Main {
public static void main(){
//link this at run time
A obj1 =new B(); //loose coupling
obj1 =new B(); //Dynamic method Dispatch
}
}
class A{
}
class B extends A{
}
class C extends A{
}
Since, during runtime show() method get selected for execution and every time we changing object and therefore method get changed at runtime this is known as dynamic method dispatch.
#2
:-- method overloading is compile time polymorphism, because linking of method get happen during compile time with object.
:-- method overriding is run time polymorphism because linking of method occur during runtime.
#3
benefit of loose coupling:
:--During enterprise level software we are working with loose coupling that time dynamic method dispatch really helpful.
:--Loose coupling allows making changes in the code easily.
:--Testing of loosely coupled structures is easier than the tightly coupled structure.
:--Less amount of code is required to make changes in a loosely coupled structure than in a tightly coupled structure.
More Learning :
Donation:
PayPal Id : navinreddy20
Patreon : navinreddy20
1)Loose coupling (Dynamic method dispatch)
2)compile time polymorphism vs runtime polymorphism
3)Benefits of Dynamic method dispatch
#1
loose coupling - using parents type reference and child type object.
Suppose we have three Class A,B and C here B and C are child of A.
in A there are show() method and both class B and c override show() method.
class Main {
public static void main(){
//link this at run time
A obj1 =new B(); //loose coupling
obj1 =new B(); //Dynamic method Dispatch
}
}
class A{
}
class B extends A{
}
class C extends A{
}
Since, during runtime show() method get selected for execution and every time we changing object and therefore method get changed at runtime this is known as dynamic method dispatch.
#2
:-- method overloading is compile time polymorphism, because linking of method get happen during compile time with object.
:-- method overriding is run time polymorphism because linking of method occur during runtime.
#3
benefit of loose coupling:
:--During enterprise level software we are working with loose coupling that time dynamic method dispatch really helpful.
:--Loose coupling allows making changes in the code easily.
:--Testing of loosely coupled structures is easier than the tightly coupled structure.
:--Less amount of code is required to make changes in a loosely coupled structure than in a tightly coupled structure.
More Learning :
Donation:
PayPal Id : navinreddy20
Patreon : navinreddy20
Комментарии