hamburger

Which collection class allows you to grow or shrink?

By BYJU'S Exam Prep

Updated on: September 25th, 2023

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:

Our Apps Playstore
POPULAR EXAMS
SSC and Bank
Other Exams
GradeStack Learning Pvt. Ltd.Windsor IT Park, Tower - A, 2nd Floor, Sector 125, Noida, Uttar Pradesh 201303 help@byjusexamprep.com
Home Practice Test Series Premium