🗃️23 questions
Java Collections
List/Set/Map internals, HashMap, ConcurrentHashMap, performance.
List vs Set vs MapHashMap InternalsConcurrentHashMapIteratorsTreeMapPerformance
Sample Questions (23 live)
List vs Set vs MapEasy
How do you choose between List, Set and Map for a new feature?
InfosysTCSCognizantRead →
ListEasy
ArrayList vs LinkedList — which would you actually pick in production, and why?
AmazonInfosysTCSRead →
SetEasy
HashSet vs LinkedHashSet vs TreeSet — when do you use each?
InfosysCognizantCapgeminiRead →
IteratorsEasy
Iterator vs ListIterator — how do you safely remove elements while iterating?
TCSInfosysAccentureRead →
HashMap InternalsMedium
Walk me through what happens inside HashMap.put() in Java 8.
AmazonMicrosoftDeloitteRead →
PerformanceMedium
How do load factor and resizing affect HashMap performance, and how do you tune it?
AmazonGoogleWiproRead →
IteratorsMedium
What causes ConcurrentModificationException, and what are the correct fixes?
InfosysCognizantAccentureRead →
HashMap InternalsMedium
How do you build an LRU cache using LinkedHashMap?
AmazonMicrosoftDeloitteRead →
TreeMapMedium
When do you reach for TreeMap/NavigableMap instead of HashMap?
AmazonGoogleDeloitteRead →
PerformanceMedium
List.of vs Collections.unmodifiableList vs Arrays.asList — what's the difference?
AmazonMicrosoftCognizantRead →
ListMedium
What are the pitfalls of Arrays.asList(), and how do they bite in production?
TCSInfosysAccentureRead →
PerformanceMedium
How do you find the top-K elements from a large stream efficiently?
AmazonGoogleMicrosoftRead →
ConcurrentHashMapMedium
When is CopyOnWriteArrayList the right choice, and when is it a trap?
AmazonDeloitteMicrosoftRead →
HashMap InternalsMedium
What happens if you mutate an object after using it as a HashMap key?
AmazonDeloitteCognizantRead →
ConcurrentHashMapHard
How does ConcurrentHashMap stay thread-safe without locking the whole map (Java 8)?
AmazonGoogleMicrosoftRead →
ConcurrentHashMapHard
Why can a plain HashMap corrupt data — or even spin the CPU — under concurrent access?
AmazonMicrosoftDeloitteRead →
IteratorsHard
Fail-fast vs fail-safe iterators — how do they work internally?
AmazonGoogleMicrosoftRead →
PerformanceHard
What's the best collection for high-contention counters — ConcurrentHashMap, AtomicLong, or LongAdder?
AmazonGoogleMicrosoftRead →
PerformanceHard
How do you reduce the memory overhead of very large Java collections?
AmazonGoogleDeloitteRead →
ConcurrentHashMapHard
How do you implement a bounded producer-consumer pipeline with BlockingQueue?
AmazonMicrosoftGoogleRead →
Sequenced CollectionsMedium
What do SequencedCollection, SequencedSet and SequencedMap (Java 21) fix that List and LinkedHashMap couldn't?
AmazonMicrosoftRead →
ConcurrentHashMapMedium
ConcurrentHashMap.size() vs mappingCount() — why does the Javadoc specifically call one of them 'an estimate'?
AmazonGoogleOracleRead →
ConcurrentHashMapMedium
ConcurrentHashMap is thread-safe — so why can a get-then-put sequence still race, and how do computeIfAbsent/merge fix it?
AmazonMicrosoftGoogleRead →
Advertisement
Google AdSense slot