I have have an interface called MyInterface and a class MyClass which is not implemented by MyInterface.
interface MyInterface {
}
class MyClass{
}
If I create an instance of MyClass, Compiler allows to cast that to MyInterface. I know that it will throw ClassCastException in runtime. But why does the compiler allow for casting?