Hi there,
This is my first post, and first off just wanted to say I was very glad to find this forum - great job !
I am reading Mughal and Rasmussen's "A programmer's Guide to
Java Cert", and according to their phrasing the compile-time check of the instanceof operator "... determines whether a reference of <source type> and a reference of <destination type> can denote objects of a reference type that is a common subtype of both <source type> and <destination type> in the type hierarchy".
They go on to give an example where the compiler will complain if you try to apply instanceof using one of their created classes and
String (for example), which I understand.
What I don't understand is the following, which is my own little variation on one of their practice questions
From all the type hirarchy diagrams I've seen in the text, I would say that interfaces I and J are on two different branches of the type hierarchy (interfaces being described as supertypes which can be assigned references of subtypes etc), as is class E. So I expected the above not to pass the compiler, but instead it did and showed "FalseJ" and "FalseE" when run.
Am I missing something here, or is their explanation incomplete ? Apparently interfaces are treated differently than named classes but I couldn't find any qualifications regarding this.
Thanks !