Multiple choice

Which of the above collections provide(s) an index based input/output?

1. Stack 2. Queue 3. BitArray 4. ArrayList 5. HashTable

  1. 1 and 2 only

  2. 3 and 4 only

  3. 5 only

  4. 1, 2 and 5 only

  5. All of the above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The BitArray class stores a compact array of bit values. These value are boolean in nature storing 0 and 1. Elements in an BitArray are accessed using an integer index which starts from 0. Arraylist represents an ordered collection of an object that can be indexed individually. It is basically an alternative to an array. However, unlike array, you can add and remove items from a list at a specified position using an index.