Multiple choice

Which of the following statements about the hashcode() method are incorrect?

  1. The value returned by hashcode() is used in some collection classes to help locate objects.
  2. The hashcode() method is required to return a positive int value.
  3. The hashcode() method in the String class is the one inherited from Object.
  4. Two new empty String objects will produce identical hashcodes.

  1. 1 and 2

  2. 2 and 3

  3. 3 and 4

  4. 1 and 4

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

An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value.