Chapter 27 Hashing
Section 27.2 What Is Hashing?
1. A hashing function .
a. stores an element in the hash table
b. maps a key to an index in the hash table
#
2. If each key is mapped to a different index in the hash table, it is called .
a. normal hashing
b. perfect hashing
#
3. A collision occurs .
a. when two or more keys are mapped to the same hash value.
b. when two elements have the same key value.
c. when two elements are mapped to the same key.
#
Section 27.3 Hash Functions and Hash Codes
5. What is the return type value for the hashCode() method?
a. byte
b. short
c. int
d. long
#
6. True or False? Two objects have the same hash codes if they are equal.
a. True
b. False
#
7. True or False? Two objects are equal if their hash codes are equal.
a. True
b. False
#
4. Every object has the hashCode() method.
a. True
b. False
#
Section 27.3.1 Hash Codes for Primitive Types
9. For an Integer object with value 20, what is its hashCode?
a. 10
b. 20