Line
IA a = new myClass();
defines object a as type IA and all that the compiler knows. He cannot assume that a is also IB, because it is entirely possible for this:
public class MyClass2 implements IA{} IA a = new MyClass2(); method(a);
in this case, a is not IB, as in your example. Therefore, the compiler makes no assumptions about the type other than what you provide. Therefore, it must call a method that accepts IA.
source share