ArrayList Method Execution
Which of the following represents the contents of numbers after the code segment has been executed?
Consider the following code segment.
ArrayList<String> numbers = new ArrayList<String>();
numbers.add("one");
numbers.add("two");
numbers.add(0, "three");
numbers.set(2, "four");
numbers.add("five");
numbers.remove(1);
Which of the following represents the contents of numbers after the code segment has been executed?
A
[“three”, “two”, “five”]
B
[“one”, “four”, “five”]
C
[“one”, “two”, “three”, “four”, “five”]
D
[“three”, “four”, “five”]
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kaisuki | 1 | 1 | 0m 00s | 100 |
| #2 | familarahimli | 1 | 1 | 0m 00s | 100 |
| #3 | upadhgau000 | 1 | 1 | 0m 00s | 100 |
| #4 | y.seong2027 | 1 | 1 | 0m 40s | 60 |
| #5 | geethasailaja | 1 | 2 | 0m 54s | 36 |
| #6 | psak12 | 1 | 1 | 1m 46s | -6 |
| #7 | singhris000 | 1 | 3 | 6m 53s | -333 |
APFIVE