Multiple choice

Which of the above two statements define the equals and hashcode contract in JAVA?

Statement -1 If two objects are equal, then their hash code must be the same.
 Statement -2 If two objects have same hash code, then may or may not be equal.

  1. Only Statement 1

  2. Only Statement 2

  3. Both 1 and 2

  4. Neither Statement 1 nor Statement 2

  5. None of the above

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

Correct choice