🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: HashMap and Maps: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. What does this print? (code)
  2. Q2. What is HashMap's default load factor?
  3. Q3. If you override equals() in a key class, what else must you override?
  4. Q4. Which Map keeps its keys sorted?
  5. Q5. Which interface lets you define MANY different sort orders outside the class?
  6. Q6. What does this print? (code)
  7. Q7. You put an object into a HashMap as a key, then change a field that its hashCode() uses. What usually happens on map.get(thatObject)?
  8. Q8. Since Java 8, what does HashMap do when one bucket collects too many entries (more than 8)?
  9. Q9. Two different keys have the same hashCode() but equals() returns false. What does HashMap do?
  10. Q10. What does this print? (code)