Java Programming - Objects and Collections - Discussion

Discussion Forum : Objects and Collections - General Questions (Q.No. 8)
8.
Which collection class allows you to access its elements by associating a key with an element's value, and provides synchronization?
java.util.SortedMap
java.util.TreeMap
java.util.TreeSet
java.util.Hashtable
Answer: Option
Explanation:

Hashtable is the only class listed that provides synchronized methods. If you need synchronization great; otherwise, use HashMap, it's faster.

Discussion:
5 comments Page 1 of 1.

Mac said:   1 decade ago
@Sanjeev Mishra.

It means that the access to the underlying collection (add, get, set, put, remove, etc.) is all synchronized. It cannot take place simultaneously and finally its Thread Safe.

Rajesh Kushwaha said:   1 decade ago
Hashtable is synchronised but HashMap is not synchronised.

So Hashtable is correct answer.

Sanjeev Mishra said:   1 decade ago
Please give me the difference between Hashtable and HashMap related to above question?

DD said:   1 year ago
Give more explanation for the answer.

Aaru said:   1 decade ago
What is synchronization in this?

Post your comments here:

Your comments will be displayed after verification.