Multiple choice technology programming languages

I defined an equals method, but Hashtable ignores it. Why?

  1. You forgot the hashCode method

  2. You didn't handle circular references properly

  3. Could be any / both of above

  4. None of above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Hashtable relies on both equals() and hashCode() to store and locate keys. If you override equals() but not hashCode(), equal objects will have different hash codes, preventing Hashtable from finding them. Circular references can also cause infinite loops or incorrect behavior during lookup.