• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

urgent questions about collection

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I met two problem with collection when doing Mock Exam. Please help!
1.You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural order. Which interface provide that capability?
A.Java.util.Map
B.Java.util.Set
C.Java.util.List
D.Java.util.SortedSet
E.Java.util.SortedMap
F.Java.util.Collection
I wonder the answer is D or E or both.
2.Which statement is true for the class java.util.Hashset?
A. THe elements in the collection are ordered.
B. The collection is guaranteed to be immutaible.
C. The elements in the collection are guaranteed to be unique.
D. The elements in the collection are accessed using a unique key.
E The elements in the collection are guranteed to be synchronized.
Is the answer should be C and D?
 
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
han,
I believe
For 1: Ans D
E requires no duplicate keys , but not elements i think
For 2: It clearly C
Becoz, HashSet does not implement Map interface so there are no
key/value issues
Thankx
 
Han Shu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Ragu!
However, I am still confused by Hashset, Hashtable, Hashmap, which one gurantee to be synchronized, and which on not?
 
Ragu Sivaraman
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Han Shu:
Thank you Ragu!
However, I am still confused by Hashset, Hashtable, Hashmap, which one gurantee to be synchronized, and which on not?



Vector and HashTable are the ones i know which is threa-safe or synchronized

 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic