Which of the following is a valid syntax to synchronize the HashMap?
Check your spam folder if password reset mail not showing in inbox????
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Map m = hashMap.synchronizeMap(); HashMap map =hashMap.synchronizeMap(); Map m1 = Collections.synchronizedMap(hashMap); Map m2 = Collection.synchronizeMap(hashMap); Answer: (c) Map m1 = Collections.synchronizedMap(hashMap); Explanation: By default, the HashMap class is a non-synchronized collRead more
Answer: (c) Map m1 = Collections.synchronizedMap(hashMap);
Explanation: 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.
Hence, the correct answer is option (c).
See less