filmov
tv
#56 Dynamic Method Dispatch in Java
Показать описание
Check out our courses:
Coupon: TELUSKO10 (10% Discount)
Coupon: TELUSKO20 (20% Discount)
Udemy Courses:
For More Queries WhatsApp or Call on : +919008963671
in this video we are discussing method dispatch
-- in previous lecture we had discussed what is polymorphism
-- in this lecture we are further talking about run time polymorphism
-- suppose we have some class A , B and C
-- class B and C extends A
-- in All three class we have show() method
-- main() method of Demo we create object of A, B and C but we create only reference of A which can hold
object of A, B and C .
class A{
public void show(){
}
}
class B extends A{
public void show(){
}
}
class C extends A{
public void show(){
}
}
public class Demo{
public static void main(String []args){
A obj =new A();
obj =new B(); //reference is A (we can use reference of parents) and create object of B and assign to parents reference variable.
obj =new B(); //reference is A (we can use reference of parents) and create object of C and assign to parents reference variable.
}
}
Note: during compile time we donot which show() method is called from which class.
-- we can know during run time which show method is called this is known as run time polymorphism.
-- all this concept is class dynamic method dispatch
More Learning :
Donation:
PayPal Id : navinreddy20
Coupon: TELUSKO10 (10% Discount)
Coupon: TELUSKO20 (20% Discount)
Udemy Courses:
For More Queries WhatsApp or Call on : +919008963671
in this video we are discussing method dispatch
-- in previous lecture we had discussed what is polymorphism
-- in this lecture we are further talking about run time polymorphism
-- suppose we have some class A , B and C
-- class B and C extends A
-- in All three class we have show() method
-- main() method of Demo we create object of A, B and C but we create only reference of A which can hold
object of A, B and C .
class A{
public void show(){
}
}
class B extends A{
public void show(){
}
}
class C extends A{
public void show(){
}
}
public class Demo{
public static void main(String []args){
A obj =new A();
obj =new B(); //reference is A (we can use reference of parents) and create object of B and assign to parents reference variable.
obj =new B(); //reference is A (we can use reference of parents) and create object of C and assign to parents reference variable.
}
}
Note: during compile time we donot which show() method is called from which class.
-- we can know during run time which show method is called this is known as run time polymorphism.
-- all this concept is class dynamic method dispatch
More Learning :
Donation:
PayPal Id : navinreddy20
Комментарии