Java OCA OCP Practice Question 1615

Question

Which type allows inserting a null value?

  • A. ArrayDeque
  • B. ArrayList
  • C. TreeSet
  • D. All of these allow nulls.


B.

Note

ArrayList allows null elements, making Option B correct.

TreeSet does not allow nulls because they need to compare the values.

ArrayDeque uses null for a special meaning, so it doesn't allow it in the data structure either.




PreviousNext

Related