Skip to content
Preptima

Core Java interview questions

Object semantics, equals and hashCode contracts, generics, exceptions, and immutability.

3 questions in Java & Spring.

medium3

mediumConceptCoding

If you override equals but not hashCode, what breaks and when?

Equal objects must produce equal hash codes. Break that and a HashMap sends lookups to a bucket the entry was never placed in, so the map holds a value you can no longer retrieve and a set silently admits duplicates. The same failure appears later if a key is mutated after insertion.

4 minentry, mid, senior