Question
Q: 1. Which of the following correctly declares an ArrayList? (3 points) I. ArrayList aList = new ArrayList (); II. ArrayList aList = new ArrayList
Q: 1.
Which of the following correctly declares an ArrayList? (3 points)
I. ArrayList
II. ArrayList
III. ArrayList
1) I only 2) II only 3) III only 4) I and II only 5) II and III only
2.
Which of the following correctly declares an ArrayList? (3 points)
I. ArrayList
II. ArrayList
III. ArrayList
1) I only 2) II only 3) III only 4) I and II only 5) I and III only
3.
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(3, "lemon");
1) apple, orange, grape, kiwi, lemon, peach, banana 2) apple, orange, grape, lemon, watermelon, peach, banana 3) apple, orange, grape, kiwi, lemon, watermelon, peach, banana 4) apple, orange, lemon, grape, kiwi, watermelon, peach, banana 5) apple, orange, grape, kiwi, watermelon, peach, banana, lemon, lemon, lemon
4.
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");
1) apple, orange, grape, kiwi, watermelon, peach, banana 2) apple, raspberry, grape, kiwi, watermelon, peach, banana 3) apple, raspberry, orange, grape, watermelon, peach, banana 4) raspberry, orange, grape, kiwi, watermelon, peach, banana 5) raspberry, apple, orange, grape, kiwi, watermelon, peach, banana
5.
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)
1) aList.add(55); 2) aList.add(5, 55); 3) aList.add(6, 55); 4) aList.add(42, 55); 5) aList.add(55, 6);
6.
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)
I. aList.remove(2, "blue");
II. aList.remove("blue");
III. aList.remove("blue", 2);
1) I only 2) II only 3) III only 4) I and II only 5) II and III only
7.
Assume aList is a valid ArrayList containing the following:
purple, red, blue, yellow, green, pink, black, gold
Which of the following removes yellow from aList? (3 points)
I. aList.remove(3);
II. aList.remove("yellow");
III. aList.remove(3, "yellow");
1) I only 2) I and II only 3) I and III only 4) II and III only 5) I, II, and III
8.
What is the size of the ArrayList aList after the following code segment is executed? (3 points)
ArrayList
1) 3 2) 5 3) 6 4) 7 5) An IndexOutOfBoundsException error occurs
9.
What is the size of the ArrayList aList after the following code segment is executed? (3 points)
ArrayList
1) 0 2) 1 3) 2 4) 4 5) 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