I do not understand this Java behavior. I have two classes:
class C1 {
public void m1(double num) {
System.out.println(\"Inside C1.m1(): \" + num
Method signatures for both methods are different.
public void m1(double num)
public void m1(int num)
So there is no overriding in this case. Now when you say
C1 c = new C2();
c.m1(10);
at compile time, it will se reference is of type C1
which has method public void m1(double num)
which is compatible with 10 [int in expanded to double]. So int is promoted to double, and the corresponding method is called (which is also what you see in the bytecodes).