Java Set MCQs with answers
99 questions tagged Java Set, each with the correct answer and an explanation. Page 1 of 5.
- Which method gets the number of elements in a Set?
- Which of the following is NOT an advantage of using Set?
- What is the result of `HashSet.toArray(new Integer[0])`?
- Which of the following is a Set backed by a concurrent skip list?
- Which method creates a stream from a Set?
- What is the best way to make a Set read-only?
- Which collection type implements both Set and SortedSet?
- Which method is used to remove all elements that satisfy a given condition?
- Which method is used to check if a Set contains all elements of a Collection?
- Which of the following is used to convert Set to List?
- What is the output of `new HashSet<>(Arrays.asList(null, null, null))`?
- How many null values can a TreeSet hold?
- What is the default capacity of a HashSet?
- Which of the following allows concurrent access and sorted elements?
- Which method retrieves but does not remove the first element of a NavigableSet?
- What happens when we add duplicate elements in LinkedHashSet?
- What will be the output of `new TreeSet<>(Arrays.asList(5, 3, 8, 1))`?
- Which of the following is TRUE about EnumSet?
- What happens if we call `remove(null)` on a HashSet that doesn't contain null?
- Which method in NavigableSet returns the least element greater than the given element?