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

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

Prepare for your Java exam with our ultimate quiz based on 'Thinking in Java'. Engage with expertly crafted questions that enhance your learning process. Perfect for Java enthusiasts looking to solidify their knowledge!

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.