Dynamic method dispatching in java
<p>The following is the code snipplet regarding my doubt.</p>

<pre><code>Class A{

void m1(A a){
   System.out.println("A");
}

}

Class B{

void m1(B a){
   System.out.println("B");
}

}

Class C{

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);    
}
}
</code></pre>

<p>Output: A</p>

<p>But I excepted the output as: C 
Because I have created the memory for C and A is refering to C's memory so, if i call the method on the A ref which is pointing to C and the argument is i passed as C type so, I am expecting the m1(C) should execute. </p>

<p>Any body can please give me the proper reason for this Behaviour. </p>

<p>Thanks in advance.......!</p>
