LearnFrenzy
Sign in Take a free test

Object Class and Wrapper Classes · Object and Wrapper Classes MCQ · Question 4

The equals–hashCode contract Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 4 Back to Exercise

Which statement is part of the contract?

  • A Equal hash codes mean equal objects
  • B If a.equals(b) is true, a.hashCode() must equal b.hashCode() Correct
  • C hashCode must be unique
  • D equals must use hashCode
Correct Answer: Option B

Different objects may share a hash code (a collision).

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links