wood burning stoves
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Dan's Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Dan Watch "Dan New topic

Dan's Question

Ashok Paulraj
Ranch Hand

Joined: Jul 07, 2003
Posts: 78
import java.util.*;
class GFC111 {
public static void main (String[] args) {
Object m = new LinkedHashMap();
System.out.print((m instanceof Collection)+",");
System.out.print((m instanceof Map)+",");
System.out.print(m instanceof HashMap);
Is the last print stmt. TRUE ?, can someone explain me.....
~ Shalini
Gian Franco
Ranch Hand

Joined: Dec 16, 2003
Posts: 977
LinkedHashMap does not implement the Collection interface
as the answer to the question says.
LinkedHashMap is a subclass of HashMap (which is a
subclass of AbstractMap, that implements the Map
interface which does NOT extend the Collection class)
Therefore System.out.print(m instanceof HashMap);
evaluates to true.
Gian Franco

"Eppur si muove!"
I agree. Here's the link: http://aspose.com/file-tools
subject: Dan's Question
It's not a secret anymore!