Java OCA OCP Practice Question 401

Question

Identify the correct statements about ArrayList?

Select 3 options

  • A. Standard JDK provides no subclasses of ArrayList.
  • B. You cannot store primitives in an ArrayList.
  • C. It allows constant time access to all its elements.
  • D. ArrayList cannot resize dynamically if you add more number of elements than its capacity.
  • E. An ArrayList is backed by an array.


Correct Options are  : B C E

Note

A. is wrong. Direct Known Subclasses: AttributeList, RoleList, RoleUnresolvedList

B. is true because only Objects can be stored in it.

C. is true because it implements java.util.RandomAccess interface, which is a marker interface that signifies that you can directly access any element of this collection.

This implies that it takes the same amount of time to access any element.

D. is wrong. It does resize dynamically. Compare that to an array, which cannot be resized once created. E. An ArrayList is backed by an array.

E. is true.

The elements are actually stored in an array and that is why is it called an ArrayList.




PreviousNext

Related