Machine-translated by Google. Questions are authored in English.
Top

Discussion

Consider what Object's default hashCode is based on. Which statement is correct?

  • A.It is a random value chosen afresh on every call to hashCode.
  • B.It is derived from the object's identity.
  • C.It is derived from the values of the object's fields.
  • D.It is derived from the object's class name.

Answer: B

The javadoc says the inherited method returns distinct integers for distinct objects as much as is reasonably practical, typically by deriving them from the object's address. It is stable for the life of the object, so it is not random, and it takes no account of field values.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.