Which of the following is a proper HashMap synchronisation syntax?
A. hashMap.synchronizeMap();
B.HashMap map = hashMap.synchronizeMap();
C. Map Collections.synchronizedMap(hashMap);
D.Collection.synchronizeMap(hashMap);
Answer:C
Which of the following is a proper HashMap synchronisation syntax?
A. hashMap.synchronizeMap(); B.HashMap map = hashMap.synchronizeMap(); C. Map Collections.synchronizedMap(hashMap); D.Collection.synchronizeMap(hashMap);
Explanation: The HashMap class is a non-synchronized collection class by default. Synchronization is required in order to conduct thread-safe operations on the class. To explicitly synchronise the HashMap class, use the Collections.synchronizedMap(hashMap) function, which returns a thread-safe map object. Collections.synchronizedMap(hashMap); Map m1 = Collections.synchronizedMap(hashMap);