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

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

Mastering Java: The Ultimate Quiz for 'Thinking in Java'. Dive deep into Java with multiple-choice questions. Challenge yourself with quiz questions designed to test and improve your understanding of the 'Thinking in Java' book. Get ready for your exam!

Practice this question and more.


Which concurrent collection class does not permit null elements?

  1. ConcurrentHashMap

  2. CopyOnWriteArrayList

  3. DelayQueue

  4. All of the above

The correct answer is: DelayQueue

A ConcurrentHashMap does not allow null keys, but it can store null values. B: CopyOnWriteArrayList does not allow null elements to be added, but it can store null elements if they are already present. D: This option is incorrect because while ConcurrentHashMap and CopyOnWriteArrayList may have some restrictions on null elements, the question is specifically about a collection class that does not permit ANY null elements, making DelayQueue the only correct answer.