I am stuck on this multiple choice questions 1 Which of the
I am stuck on this multiple choice questions.
1. Which of the following is NOT one of the 3 main categories of collections? In other words, which of these objects does not, itself, represent a collection of items? ___
2.
Which of the following is true about Lists and Sets?
3.
Which of the following may be used to examine every item in the List<String> myList?
Option A:
Option B:
Option C:
4.
Which of the following may be used to examine every item in the Set<String> mySet?
Option A:
Option B:
Option C:
5.
Every key in a Map must be unique. What happens when a Map receives a \'put\' message specifying a key that is already used in the Map?
6.
Which of the following could be an \"expensive\" operation (an operation that takes a long time to complete) in an ArrayList?
7.
Which of the following could be an \"expensive\" operation in the SimpleLinkedList class we discussed?
8.
What will be the contents of myList, in the correct order, after the following sequence of operations? (Assume all operations are supported by the list implementation used.)
9.
What will be the contents of mySet, regardless of order, after the following sequence of operations? (Assume all operations are supported by the set implementation used.)
10. What will be the contents of myMap, regardless of order, after the following sequence of operations? (Assume all operations are supported by the map implementation used.) Answers are shown as key=value pairs.
| Lists are indexed; Sets are not. |
Solution
1. options are not available
2. Both of the above.
3. Any of the above.
4. Either B or C, but not A.
5. The map entry for the key is updated -- its associated value is replaced by the new value specified, and the old value is returned by the \'put\' method.
6. b. adding a new item at the beginning of the list
You need to shift all ele,entd from second position to last left by one
7. using get(itemNumber) to examine a list item in the middle of the list (you need to travrse)
8.c. [ \"red\", \"black\", \"green\", \"red\" ]
9.[ \"black\", \"green\", \"red\" ]
10. [ \"orange\"=\"blue\", \"red\"=\"yellow\", \"blue\"=\"black\" ]

