please explain me dynamic methos dispatch
Can any one explain me how the following code executes::
class A
{
void m1(A a)
{
System.out.println("A");
}
}
class C extends A
{
void m1(C a){
System.out.println("C");
}
}
class Dmd
{
public static void main(String args[])
{
A ac = new C();
C c = new C();
ac.m1(c);
}
}
OUTPUT:: A
i am ajay doing b.tech .
hello in the above example i am sending reference c as argument and i though the output will be "C" but unfortunately it was "A"
i am unable to understand what is happening can any one say me
Thanks in advance...