Dynamic Method Dispatch in Java | Runtime Polymorphism
Dynamic Method Dispatch in Java
Dynamic Method Dispatch is the type of reference variable which is irrelevant while choosing a particular version of the overridden method for invocation. It is an important mechanism in Java that is used to implement runtime polymorphism.
Dynamic Method Dispatch is a method that is resolved at runtime instead of compile-time, which means that the choice of the version of the overridden method to be executed in response to a method call is done at runtime.
class test
{
public void method()
{
System.out.println("Hello World");
}
}
class temp extends test
{
public void method()
{
System.out.println("Hello Java");
}
}
class dynamic_dis
{
public static void main(String args[])
{
test t1=new temp();
t1.method();
}
}
Output:
Hello Java