Which of the following is a valid syntax to synchronize the HashMap?
Answer with explanationAnswer: Option C
By default, the HashMap class is a non-synchronized collection class. The need for synchronization is to perform thread-safe operations on the class. To synchronize the HashMap class explicitly, we should use the Collections.synchronizedMap(hashMap) method that returns a thread-safe map object.
Map m1 = Collections.synchronizedMap(hashMap);
Discuss about the question