Which of the most suitable java collection class for storing various currencies and their equivalent prices in USD if multiple threads access and modify this data? It is required that class should be synchronized inherently
-
HashSet
-
Vector
-
HashMap
-
TreeMap
-
None of the above
E
Correct answer
Explanation
The question requires storing currencies (keys) with USD prices (values) in a thread-safe manner. HashSet and HashMap are not synchronized. Vector is synchronized but is a List, not a Map. TreeMap is not inherently synchronized. Hashtable would be the correct synchronized Map choice, but it's not listed. Therefore 'None of the above' is correct.