And the explanation for the answer is LinkedHashMap does not implement the Collection interface. LinkedHashMap extends HashMap and implements Map, Cloneable and Serializable.
But as per my knowledge LinkedHashMap does not extend HashMap
Please correct me if i'm wrong..
Thank u! GMP[/qb]<hr></blockquote>
Hi Ganesh: The output is absolutely correct. Here, (i) m instanceof Collection --> Now since m is a type of Map and Maps do not implement Collection interface.Hence, m is not an instanceof Collection. So, It's FALSE
(ii) m instanceof Map----> As I said earlier m is a type of Map hence m is a instanceof Map. It's TRUE
(iii) m instanceof HashMap---> Here since the runtime type of m is LinkedHashMap,So m is basically a type of LinkedHashMap which extends HashMap. Hence, m is an instanceof HashMap.It's TRUE.