Multiple ChoiceBeginner 45s
LSP and equals/hashCode contract
A subclass overrides equals but not hashCode. Which LSP-adjacent contract break most directly bites when instances go into a HashSet?
Options
- 1equals becomes slower to call. It must scan every element in the hash-based collection.
- 2hashCode throws at runtime. It fails for every element inserted into the collection.
- 3The subclass can no longer be compared for equality. It cannot be compared with anything else.
- 4Equal objects can receive different hash codes, so the set treats them as distinct
Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.