Check out our courses:
Java Full Stack and Spring AI - [ Ссылка ]
Coupon: TELUSKO10 (10% Discount)
DevOps with AWS: From Basics to Mastery : [ Ссылка ]
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development : [ Ссылка ]
Coupon: TELUSKO20 (20% Discount)
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
[ Ссылка ]
Ещё видео!