I have two classes:
public class ClassA { public void method(Number n) { System.out.println(\"ClassA: \" + n + \" \" + n.getClass()); } }
In overloading, method resolution always takes care by compiler based on reference type. So, In overloading runtime object[new ClassB()] does not play any role. Therefore, in your case the method of ClassA was executed.
ClassA a = new ClassB(); a.method(3);