Java Objective Questions with Answers for written test exams 9

Question 9

Which is the most suitable Java collection class for storing various companies and their stock
prices? It is required that the class should support synchronization inherently.
Choices:
• A. Hashtable
• B. HashMap
• C. LinkedHashMap
• D. HashSet
• E. TreeMap

Answers 9


• A
Explanation:
To store the company names and their corresponding stock prices, a Map implementation
would be appropriate because it stores key-value pairs. HashSet is not the correct answer
because it does not implement the Map interface. Hashtable, HashMap, TreeMap, and
LinkedHashMap are the classes that implement the Map interface. Among these, only the
Hashtable class is inherently synchronized.


  







Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---