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
#
10. Suppose the rule of the party is that the participants who arrive later will leave
earlier. Which data structure is appropriate to store the participants?
A. Stack
B. Array List
C. Queue
D. Linked List
#
11. Suppose your program frequently tests whether a student is in a soccer team, what is
the best data structure to store the students in a soccer team?
A. ArrayList
B. HashSet
C. TreeSet
D. LinkedList
E. Vector
#
12. Suppose your program frequently tests whether a student is in a soccer team and also
need to know the student’s information such as phone number, address, and age,
what is the best data structure to store the students in a soccer team?
A. ArrayList
B. HashMap