← Quiz: HashMap and Maps: all 10 questions
Quiz: HashMap and Maps · Question 3 of 10
If you override equals() in a key class, what else must you override?
If you override equals() in a key class, what else must you override?
- A.toString()
- B.hashCode()
- C.compareTo()
- D.finalize()
Answer & explanation
Correct answer: hashCode()
Equal objects must have equal hash codes, or HashMap and HashSet won't find them.
Can you get the rest right without peeking?
Take the timed Quiz: HashMap and Maps quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →