Multiple choice

Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?

  1. java.util.HashSet

  2. java.util.LinkedHashSet

  3. java.util.List

  4. java.util.ArrayList

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

All of the collection classes allow you to grow or shrink the size of your collection.ArrayList provides an index to its elements. The newer collection classes tend not to have synchronized methods. Vector is an older implementation of ArrayListfunctionality and has synchronized methods; it is slower than ArrayList.