Recently I observed a noticeable behavior of Instanceof operator while working with interfaces and classes. Let me explain with an example.InstanceOfDemo.java
When I try to compile the above program, I end up in compiler error.
It is because Java does not support multiple class inheritance, so it is known during the compilation that an object of type B cannot be a subtype of C. On the other hand, it is possible that obj can be an instance of interface A.InstanceOfDemo.java
You may like
Explain Loop inversion in Java
Check whether I have JDK or JRE in my system
How to check whether string contain only whitespaces or not?
How to call base class method from subclass overriding method?
Can an interface extend multiple interfaces in Java?