← 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 →- Q1. What does this print? (code)
- Q2. What is HashMap's default load factor?
- Q3. If you override equals() in a key class, what else must you override?
- Q4. Which Map keeps its keys sorted?
- Q5. Which interface lets you define MANY different sort orders outside the class?
- Q6. What does this print? (code)
- 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)?
- Q8. Since Java 8, what does HashMap do when one bucket collects too many entries (more than 8)?
- Q9. Two different keys have the same hashCode() but equals() returns false. What does HashMap do?
- Q10. What does this print? (code)