Check out our courses:
Enterprise Java Spring Microservices:
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development :
Coupon: TELUSKO20 (20% Discount)
Udemy Courses:
Java:-
Spring:-
Java For Programmers:-
For More Queries WhatsApp or Call on : +919008963671
website :
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(){
Systeem.out.println("in show A");
}
}
class B extends A{
public void show(){
Systeem.out.println("in show B");
}
}
class C extends A{
public void show(){
Systeem.out.println("in show C");
}
}
public class Demo{
public static void main(String []args){
A obj =new A();
obj.show(); //Output: in show 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.show(); //Output: in show B
obj =new B(); //reference is A (we can use reference of parents) and create object of C and assign to parents reference variable.
obj.show(); //Output: in show C
}
}
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
Github repo :
Java:-
Spring:-
More Learning :
Java :-
Python :-
Django :-
JavaScript :-
Node JS :-
Rest Api :-
Servlet :-
Spring Framework :-
Design Patterns in Java :-
Docker :-
Blockchain Tutorial :-
Corda Tutorial:-
Hyperledger Fabric :-
NoSQL Tutorial :-
Mysql Tutorial :-
Data Structures using Java :-
Git Tutorial :-
Donation:
PayPal Id : navinreddy20