Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Dive into the depths of Java with our quiz based on "Thinking in Java, Fourth Edition" by Bruce Eckel. Test your knowledge, solidify concepts, and prepare for certification with challenging questions and insightful feedback.

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


In hashing, what causes a rehash to occur?

  1. When the load factor is exceeded

  2. After every insert operation

  3. Whenever a collision occurs

  4. When the hashtable is full

The correct answer is: When the load factor is exceeded

When using hashtables, a rehash occurs when the load factor, or the ratio of the number of elements in the hashtable to the size of the hashtable, exceeds a certain threshold. This allows for the hashtable to maintain its efficient time complexity for operations such as insertion and retrieval. Rehashing does not occur after every insert operation or whenever a collision occurs, as these events may not significantly affect the load factor. A rehash also does not occur when the hashtable is full, as this would result in the hashtable being unable to store any more elements.