4.3.13.A reference to an object can be cast into a reference to an object of its implemented super interface
public class MainClass{ public static void main(String[] argv){
MyInterface i = new MyClass();
}
}
interface MyInterface{ public void aMethod();
} interface MySubinterface extends MyInterface{ public void bMethod();
} class MyClass extends MySubinterface{
public void aMethod(){
} public void bMethod(){
}
}
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Type mismatch: cannot convert from MyClass to MyInterface
at MainClass.main(MainClass.java:3)