Collections Framework – Multiple Choice Questions (MCQs)
-
-
26. How do you sort a `List` of objects using a custom `Comparator`?
-
27. Which class provides static methods for operating on collections?
-
28. What is the purpose of the `Collections.sort()` method?
-
29. What is the purpose of the `Collections.shuffle()` method?
-
30. What is the purpose of the `Collections.reverse()` method?
-
31. What is the purpose of the `Collections.binarySearch()` method?
-
32. What is the time complexity of accessing an element by index in an `ArrayList`?
-
33. What is the time complexity of accessing an element by index in a `LinkedList`?
-
34. What is the average time complexity of searching for an element in a `HashSet`?
-
35. What is the average time complexity of searching for an element in a `TreeSet`?
-
36. What is the average time complexity of getting a value by key in a `HashMap`?