The answer would still be the same (Andre said the same thing too). There can be a class which extends A and implements I. So the compiler has to allow the cast. Suppose I have a method like this
How can the compiler not allow the cast. This cast may actually be successful at runtime. We don't know what is the actual object passed to this method. The object might be of a class C which extends A and implements I. We have not created the class C right now but that doesn't mean we can't in the future. Or see it this way, suppose you are developing a library, then others might extend your classes. Lets take the java API for example. If I create this type of code
The
Thread class doesn't implement Comparable. But I might create a Thread subclass which also implements Comparable. And someone else might use my comparable-thread class. So the cast will have to be allowed...