• 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

Duplicates in collections

 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please select collection(s) that do not reject duplicates ()
A. java.util.List
B. java.util.Set
C. java.util.Map
D. All of the above
I know that Set rejects duplicates in the sense it just ignores if we add again the same element.
Map doesn't reject but updates the values for the same key value.
List happyly accepts any number of duplicates.
So I answered the above question with B. But the Mock says both B and C are correct.
Can any one explain?
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The question is not well worded.
Given that no duplicate keys will be contained in a Map, the aswer is including Map.
Because "rejecting duplicates" could be thought as producing an error, or the Map not containing the seconddly added object, misinterpretations are possible.
reply
    Bookmark Topic Watch Topic
  • New Topic