Skip to content
Sharp

Engineering Interviews · interview question

In a multi-threaded environment, which of the following is a potential issue when using HashMap?

Multiple choiceMediumchapter-20-curatedpremiumengineering-interviewscode-review-spotting-bugs
Choose one answer
Answer and explanation

Correct answer

D. ConcurrentModificationException

Why

HashMap is not synchronized, and if it is modified concurrently by multiple threads, it may lead to a ConcurrentModificationException. For thread safety, consider using ConcurrentHashMap.

Test yourself on Engineering Interviews

A free test with instant, explained results. No account needed.

Start free test
All Engineering Interviews questions →