Question
1. Which of the following correctly declares an ArrayList? (3 points) ArrayList aList = new ArrayList (10); ArrayList aList = new ArrayList (); ArrayList aList
1.
Which of the following correctly declares an ArrayList? (3 points)
- ArrayList
aList = new ArrayList (10); - ArrayList
aList = new ArrayList (); - ArrayList
aList = new ArrayList (10);
I only | |
II only | |
III only | |
I and II only | |
II and III only |
2.
Assume aList is a valid ArrayList containing the following string values: apple, orange, grape, kiwi, watermelon, peach, banana When the following statement executes, what does aList contain? (3 points) aList.set(1, "raspberry");
apple, orange, grape, kiwi, watermelon, peach, banana | |
apple, raspberry, grape, kiwi, watermelon, peach, banana | |
apple, raspberry, orange, grape, watermelon, peach, banana | |
raspberry, orange, grape, kiwi, watermelon, peach, banana | |
raspberry, apple, orange, grape, kiwi, watermelon, peach, banana |
3.
Assume aList is a valid ArrayList containing the following values: 3, 95, 86, 11, 18, 42, 73 Which of the following places 55 immediately before 42 in aList? (3 points)
aList.add(55); | |
aList.add(5, 55); | |
aList.add(6, 55); | |
aList.add(42, 55); | |
aList.add(55, 6); |
4.
Assume aList is a valid ArrayList containing the following: purple, red, blue, yellow, green, pink, black, gold Which of the following removes blue from aList? (3 points)
- aList.remove(2, "blue");
- aList.remove("blue");
- aList.remove("blue", 2);
I only | |
II only | |
III only | |
I and II only | |
II and III only |
5.
What is the size of theArrayList aList after the following code segment is executed? (3 points) ArrayList
3 | |
4 | |
7 | |
9 | |
An IndexOutOfBoundsException error occurs |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started