Which collection class allows you to grow or shrink?

By Priyanshu Vaish|Updated : June 27th, 2022

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.LinkedHashSet
  2. java.util.HashSet
  3. java.util.ArrayList
  4. java.util.HashSet

Answer C. java.util.Arraylist

The java.util.Arraylist collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized.

Solution

The answer to the question- Which collection class allows you to grow or shrink? is java.util.Arraylist. You can increase or decrease the size of your collection using any of the collection classes. The elements of an array list have an index. Synchronized methods are typically absent from the more recent collection classes. Vector is a slower version of ArrayList that has synchronized methods and is an older implementation of the functionality of ArrayList.

The Java collections framework's LinkedHashSet class offers functionality of linked list and hashtable data structure. The Set interface is implemented by it. Similar to HashSet, LinkedHashSet elements are kept in hash tables.

☛ Related Questions:

Comments

write a comment

Follow us for latest updates