Infosys Interview Question

They asked me to explain the difference between HashMap and ConcurrentHashMap and where each should be used.

Interview Answer

Anonymous

Feb 21, 2026

I explained that HashMap is not thread-safe and is suitable for single-threaded environments, while ConcurrentHashMap is thread-safe and designed for concurrent access in multi-threaded applications. I also mentioned internal locking mechanisms and performance differences.