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
Life is easy because we write the source code.....
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.