This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Dan Watch "Dan New topic
Author

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
blacksmith
Ranch Hand

Joined: Dec 16, 2003
Posts: 977
Taurean,
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