tarunsinghdev / DSA-CRACKER

This is an attempt to solve 450 questions carefully curated by Love Babbar.
109 stars 65 forks source link

Dynamic method dispatch in Java (OOP concept) #76

Closed ankit351104 closed 1 year ago

ankit351104 commented 1 year ago

Dynamic method dispatch is the mechanism in which a call to an overridden method is resolved at run time instead of compile time. This is an important concept because of how Java implements run-time polymorphism.

Java uses the principle of ‘a superclass reference variable can refer to a subclass object’ to resolve calls to overridden methods at run time. When a superclass reference is used to call an overridden method, Java determines which version of the method to execute based on the type of the object being referred to at the time call.