Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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 The Software Craftsman this week in the Agile forum!
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!"
 
Have you tried LearnNowOnline? http://www.learnnowonline.com/
 
subject: Dan's Question