All 44 questions

  1. How does HashMap store and look up entries using hashCode and equals?

    Asked in 7 of 158 interviews · last asked Oct 16 · Concept · Senior

    Show answer

    HashMap stores entries in an array of buckets. It mixes the key’s hashCode() and uses (capacity - 1) & hash to choose a bucket. Within that bucket, it checks the stored hash, then matches keys by identity or equals(). Collisions use linked lists or, in Java 8+, red-black trees when size thresholds are met.

    • Equal keys must have equal hash codes; equal hash codes do not always mean equal keys.
    • Putting an equal key replaces its value rather than adding another entry.
    • Bucket counts are powers of two; tree conversion also requires a large enough bucket array.
    • Lookup is O(1) on average with well-distributed hashes.

    What the interviewer checks: The interviewer checks whether you can explain bucket selection, key matching, and collision handling.

    Common mistake (in 4 of 7 reviewed answers): Many answers forget that the hash must become a bucket index before HashMap searches for a matching key.

    Other ways it was asked
    • “How does Java's HashMap work?”
    • “How does HashMap work in Java?”
    • “How does HashMap handle internal operations in modern Java?”
  2. What are the differences between ArrayList and LinkedList in Java?

    Asked in 6 of 158 interviews · last asked Oct 16 · Concept · Junior

    Show answer

    ArrayList uses a resizable array, while LinkedList uses doubly linked nodes. ArrayList gives fast indexed access and usually uses less memory. LinkedList has slower indexed access but constant-time additions and removals at either end. I usually choose ArrayList for a general-purpose list.

    • Both implement List; LinkedList also implements Deque for queue and double-ended queue operations.
    • Indexed access is O(1) for ArrayList and O(n) for LinkedList.
    • ArrayList appends take amortized O(1); middle insertions and removals take O(n) because elements shift.
    • LinkedList insertions and removals through an already-positioned iterator take O(1); finding that position can take O(n).

    What the interviewer checks: The interviewer checks whether you can connect storage structure to operation costs and choose the right list.

    Other ways it was asked
    • “What is the difference between ArrayList and LinkedList?”
    • “What is the difference between Java's ArrayList and LinkedList?”
    • “What is the difference between the List interface and LinkedList in Java?”
  3. What is the difference between an array and an ArrayList in Java?

    Asked in 5 of 158 interviews · last asked Oct 22 · Concept · Junior

    Show answer

    An array has a fixed length, while an ArrayList can grow or shrink as you add or remove elements. Arrays can hold primitive values or object references. An ArrayList holds only object references, so primitive values use wrapper types such as Integer.

    • Use array.length for an array and list.size() for an ArrayList.
    • Access array elements with array[index]; use get(index) and set(index, value) for an ArrayList.
    • ArrayList implements the List interface; List defines operations, while ArrayList provides an implementation.
    • Both provide fast access by index, but ArrayList may shift elements when inserting or removing.

    What the interviewer checks: The interviewer checks whether you understand fixed length, resizing, element types, and the difference between List and ArrayList.

    Other ways it was asked
    • “What is the difference between an array and an ArrayList?”
    • “What is the difference between ArrayList and List in Java?”
    • “How is an array different from an ArrayList?”
  4. How does HashMap handle collisions, and how did Java 8 change this with treeified buckets?

    Asked in 5 of 158 interviews · last asked Oct 17 · Concept · Mid-level

    Show answer

    HashMap stores colliding keys in the same bucket and checks key equality to find the right entry. Before Java 8, buckets used linked lists. Java 8 added red-black trees for crowded buckets to make collision-heavy lookups faster.

    • OpenJDK Java 8 put treeifies on the ninth bucket entry when table capacity is at least 64.
    • Below that capacity, HashMap expands the table instead of treeifying the bucket.
    • Tree lookup is usually O(log n), but equal-hash, non-comparable keys can still require O(n).
    • Equal keys replace existing values; sharing a bucket does not make keys equal.

    What the interviewer checks: The interviewer checks whether you understand collisions, treeification conditions, and the limits of the performance improvement.

    Other ways it was asked
    • “How did HashMap improve collision handling after Java 8?”
    • “What changed in HashMap collision handling after Java 8?”
    • “In Java, explain how HashMap handles collisions internally, and what changes when a bucket gets treeified.”
  5. In Java, how does an ArrayList grow internally when it runs out of capacity, and what happens to existing elements during that growth?

    Asked in 4 of 158 interviews · last asked Oct 22 · Concept · Mid-level

    Other ways it was asked
    • “In Java, when an ArrayList grows past capacity, what happens to its backing storage and what does that imply for existing element references and indices?”
    • “In Java, what happens internally when you add an element to an ArrayList beyond its current capacity? How is the backing array resized, and how are existing elements moved?”
    • “What is the default capacity of a Java ArrayList, and how does it grow when you add more elements?”
  6. What is the Java Collections Framework, and what collections does it provide?

    Asked in 4 of 158 interviews · last asked Sep 8 · Concept · Junior

    Other ways it was asked
    • “Can you explain the Java Collections Framework?”
    • “What is the Java Collections Framework, and what are its main components?”
    • “Can you tell me what the Java collections are?”
  7. What are the differences between List, Set, Queue, and Map in Java?

    Asked in 3 of 158 interviews · last asked Oct 8 · Concept · Junior

    Other ways it was asked
    • “What is the difference between a List, a Set, and a Map?”
    • “What is the difference between List and Set?”
    • “What is the difference between List, Queue, and Set in Java?”
  8. What is a HashMap?

    Asked in 3 of 158 interviews · last asked May 1 · Concept · Junior

    Other ways it was asked
    • “What is a HashMap in Java?”
  9. What is the difference between a HashMap and a HashSet?

    Asked in 2 of 158 interviews · last asked Jul 31 · Concept · Junior

  10. How is LinkedList implemented internally, and what memory overhead do its node references add compared with ArrayList?

    Asked in 2 of 158 interviews · last asked Oct 17 · Concept · Mid-level

    Other ways it was asked
    • “How is a LinkedList implemented internally in Java?”
    • “In Java, how is a LinkedList node structured, what references does it hold, and what extra memory cost does that imply per element versus an ArrayList?”
  11. In a HashMap, what exactly happens during a resize or rehash, how are buckets redistributed, and what determines which bucket an existing entry moves to?

    Asked in 2 of 158 interviews · last asked Oct 17 · Concept · Senior

    Other ways it was asked
    • “In Java, what happens during HashMap resizing and rehashing? How are entries redistributed across the new table without recomputing every hash from scratch?”
  12. What do you understand by hashing in Java?

    Asked in 2 of 158 interviews · last asked Sep 16 · Concept · Junior

    Other ways it was asked
    • “What is hashing in Java?”
  13. What characterizes a good HashMap key, how does a HashMap work, what is a collision, and what contract must keys follow?

    Asked once · last asked Mar 6 · Concept · Mid-level

  14. If an object used as a HashMap key changes a field that contributes to its hash code, what happens?

    Asked once · last asked Mar 25 · Scenario · Mid-level

  15. What is the difference between a LinkedList and a HashMap?

    Asked once · last asked Apr 8 · Concept · Junior

  16. What is the difference between a cache and a Java Map, and when would you use each?

    Asked once · last asked Apr 23 · Concept · Junior

  17. What are Java generics, and how can you use them in a project?

    Asked once · last asked Aug 5 · Concept · Junior

  18. How is a HashMap structured, and when would you use a HashMap instead of a List?

    Asked once · last asked Aug 5 · Concept · Mid-level

  19. Does a HashMap allow null keys and values?

    Asked once · last asked Aug 6 · Concept · Junior

    Other ways it was asked
    • “Can you write code demonstrating whether a HashMap allows null keys and values?”
  20. In Java, how does HashMap determine which bucket a key goes into, and what roles do hashCode and equals play during put and get?

    Asked once · last asked Sep 11 · Concept · Mid-level

  21. In Java HashMap, what triggers treeification of a bucket, and what are the thresholds for treeifying and untreeifying?

    Asked once · last asked Sep 11 · Concept · Senior

  22. In Java, how do ArrayDeque and LinkedList compare as queues? How is ArrayDeque laid out in memory, and how does it handle wraparound as the head and tail move?

    Asked once · last asked Sep 11 · Concept · Senior

  23. How does a HashSet work internally in Java?

    Asked once · last asked Sep 16 · Concept · Mid-level

  24. What is the difference between HashMap and TreeMap?

    Asked once · last asked Sep 18 · Concept · Mid-level

  25. What are the typical time and space complexities of common HashMap and HashSet operations in Java?

    Asked once · last asked Sep 22 · Concept · Mid-level

  26. What is the difference between fail-fast and fail-safe iterators?

    Asked once · last asked Sep 22 · Concept · Mid-level

  27. What is the difference between Collection and Collections?

    Asked once · last asked Sep 30 · Concept · Junior

  28. What is the difference between HashSet and TreeSet?

    Asked once · last asked Sep 30 · Concept · Junior

  29. How does Arrays.sort behave differently for Integer arrays versus String arrays?

    Asked once · last asked Oct 2 · Concept · Junior

  30. Which sorting algorithm does Java's Arrays.sort use for object arrays?

    Asked once · last asked Oct 2 · Concept · Junior

  31. Why is String a good HashMap key?

    Asked once · last asked Oct 16 · Concept · Mid-level

  32. In Java, what happens internally when you remove an element from the middle of an ArrayList? How are the remaining elements laid out afterward?

    Asked once · last asked Oct 17 · Concept · Mid-level

  33. How do wildcards work in Java generics?

    Asked once · last asked Oct 22 · Concept · Mid-level

  34. What characterizes a good key in a HashMap?

    Asked once · last asked Mar 6 · Concept · Mid-level

  35. What is the Java Collections Framework?

    Asked once · last asked Apr 8 · Concept · Junior

    Other ways it was asked
    • “What is the Collection Framework?”
  36. How would you search for an item in a Java collection?

    Asked once · last asked May 25 · Concept · Junior

  37. What types of collections are available in Java?

    Asked once · last asked Jul 27 · Concept · Junior

  38. Can you differentiate between ArrayList and HashMap?

    Asked once · last asked Aug 5 · Concept · Junior

  39. How is Map different from HashMap in Java?

    Asked once · last asked Sep 4 · Concept · Junior

  40. What is the use of LinkedHashMap?

    Asked once · last asked Sep 18 · Concept · Mid-level

  41. What are collisions in a HashMap?

    Asked once · last asked Oct 6 · Concept · Mid-level

  42. What is type erasure?

    Asked once · last asked Oct 9 · Concept · Junior

  43. What is your favorite Java collection, and why might you prefer it over a dynamic array?

    Asked once · last asked Oct 13 · Concept · Mid-level

  44. In Java, how does an ArrayDeque store elements internally, and what happens when it becomes full and needs to grow?

    Asked once · last asked Oct 17 · Concept · Mid-level

    Other ways it was asked
    • “In Java, how does a deque store elements internally, and what happens when it becomes full and needs to grow?”

More Java interview questions

How this list is made

Every question here was asked by a real interviewer in a real job interview that a candidate ran MeetAssist in. After the call, the interviewer's questions are pulled from the transcript. Practice sessions, tests, exams and anything that was not a job interview are dropped.

Questions are rewritten so they make sense on their own: names of people, employers and clients are removed, and speech-to-text mistakes are fixed. Small talk, logistics and questions about one candidate's own résumé are left out. Rephrasings of the same question are merged, and the count is the number of different interviews it came up in.

The interviews come from candidates who use MeetAssist, so they lean towards software, data and AI roles: the shares describe these interviews, not every Java interview. Answers to the most asked questions are written and checked by an editor; a "common mistake" is shown only when reviews of real answers in these interviews show it, with the count.

158 interviews, 100 candidates, Sep 2025 to Oct 2026. Updated every month with new interviews.