A. new LinkedList(new String[]{“red”, “green”, “blue”})
B. lst.sort()
C. Arrays.sort(lst)
D. Collections.sort(lst)
#
6. To find a maximum object in an array of strings (e.g., String[] names = {“red”,
“green”, “blue”}), use
A. Arrays.max(names)
B. Collections.max(Arrays.asList(names))
C. Arrays.sort(names)
D. Collections.max(names)
E. None of the above
#
7. Which method do you use to remove an element from a set or list named x?
A. x.remove(element)
B. x.removes(element)
#
8. To create a set that consists of string elements “red”, “green”, and “blue”, use
A. new HashSet<String>(new String[]{“red”, “green”, “blue”})
B. new Set<String>(Arrays.asList(new String[]{“red”, “green”, “blue”}))
C. new HashSet<String>(Arrays.asList(new String[]{“red”, “green”, “blue”}))
D. new HashSet<String>({“red”, “green”, “blue”})
#
9. Which of the data types below could be used to store elements in their natural order
based on the compareTo method.
A. TreeSet
B. Collection