Following interface and classes are successfully compiled. Problem is mentioned in the output below :
interface MyInterface{} class MyClass imp
At run time there should be a real object (or null) behind the reference mi. The real type will implement this interface hence the compiler allows it. At run time any type that implements that interface could be there.