Question library
Questions from real interviews. Drill any of them by voice in a couple of minutes, with an interviewer, a score and feedback.
How does a HashMap work internally? What happens when you call put?JuniorWhat is the equals and hashCode contract, and what happens if you break it?JuniorWhat's the difference between ArrayList and LinkedList, and when would you choose each?JuniorWhich data structures from the collections module do you know, and what are they for?JuniorExplain how HashMap works internally, and what happens if you put an object in as a key and then change a field that's used in hashCode.Mid-levelImplement an LruCache class with a fixed capacity passed to the constructor. The get method returns the value for a key or null, the put method stores a key-value pair, and when the cache overflows, the element that hasn't been accessed for the longest time is evicted. Both operations must run in constant time.Mid-levelWrite a class FlatIterator that takes a list of lists of integers and implements the Iterator interface: hasNext tells you whether there are elements left, and next returns the next number, going through all the nested lists in order. You're not allowed to copy all the elements into one combined list up front.Mid-levelHow does ConcurrentHashMap work in modern versions of Java, and how is its internal structure different from a regular HashMap?Senior