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?
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
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