If the class is not a final class, the compiler can not determine what interfaces are implemented by it. Even if the class does not implement the interface, but one of its subclass might. If the actually object class does not implement the interface then you will get "false" at runtime. And String class is final so you get compile time error
Joined: Sep 01, 2011
But it does not compile even if I put Feline or BarnCat instead of Animal at 14. But if I put any interface at 14. instead of Animal it compiles. I'm confused
Comparing a class and an interface is always valid, because it's always possible to extend the class and implement the interface at the same time.
For example: Because of that, the test could work. The compiler will prevent comparisons that cannot work, which is when you have two classes from different inheritance branches. But because you can implement multiple interfaces, as soon as one of them is an interface the compiler has to allow it.