• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Collections

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found this question in a mock:
Which contains objects without ordering, duplication and any lookup/retrieval mechanism?
A.Map
B.Set
C.List
D.Collections
E.Enumeration
Answer given:B
I don't understand why Set is the correct answer. There is no ordering and duplication of objects in Set but it has an iterator (inherited from Collection interface). And this iterator can be used as lookup/retrieval mechanism. Isn't it??
Can anyone help with this!!
And correct answer if this is not.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As you say, this question could be improved. You can see what the author's intent was, but the objections you raise are valid - it just goes to show how hard it is to write questions that get to the point, are not trivial, and can't be misinterpreted.
For instance, you could interpret the Set method contains that returns true or false depending on if an object is a memeber as a lookup method.
Bill
 
Anushkha Rana
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


For instance, you could interpret the Set method contains that returns true or false depending on if an object is a memeber as a lookup method.


Well! Set interface do have such a method contains(). Isn't it??
from API doc


public boolean contains(Object o)
Returns true if this set contains the specified element. More formally, returns true if and only if this set contains an element e such that (o==null ? e==null : o.equals(e)).

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic