Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Dan's Question  RSS feed

 
Ashok Paulraj
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 979
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!