aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes urgent questions about collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "urgent questions about collection" Watch "urgent questions about collection" New topic
Author

urgent questions about collection

Han Shu
Greenhorn

Joined: Sep 03, 2001
Posts: 9
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?
Ragu Sivaraman
Ranch Hand

Joined: Jul 20, 2001
Posts: 464
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

Joined: Sep 03, 2001
Posts: 9
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

Joined: Jul 20, 2001
Posts: 464
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

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: urgent questions about collection