Exposure Java Multiple Choice Test Arraylist Class: This Test Is A Key Do Not Write On This Test
Exposure Java Multiple Choice Test Arraylist Class: This Test Is A Key Do Not Write On This Test
01. Which of the following statement describes dynamic resizing as is applies to the ArrayList class?
Exposure Java 2013, APCS Edition Chapter 11 Test Page 1 Updated: 05-16-13
03. What is the output of this program segment?
Exposure Java 2013, APCS Edition Chapter 11 Test Page 2 Updated: 05-16-13
05. Consider the following code segment.
Exposure Java 2013, APCS Edition Chapter 11 Test Page 3 Updated: 05-16-13
07. What is the output of this program segment?
(A) [Jessica, Isolde, Jessica, John, Jessica, Greg, Jessica, Maria, Jessica, Heidi]
(B) [Isolde, John, Greg, Maria, Heidi, Jessica, Jessica, Jessica, Jessica, Jessica]
### (C) [Jessica, Jessica, Jessica, Jessica, Jessica, Isolde, John, Greg, Maria, Heidi]
(D) [Isolde, Jessica, John, Jessica, Greg, Jessica, Maria, Jessica, Heidi, Jessica]
(E) Error
(A) [Jessica, Isolde, Jessica, John, Jessica, Greg, Jessica, Maria, Jessica, Heidi]
### (B) [ Jessica, Jessica, Jessica, Jessica, Jessica]
(C) [ Isolde, John, Greg, Maria, Heidi]
(D) [Isolde, Jessica, John, Jessica, Greg, Jessica, Maria, Jessica, Heidi, Jessica]
(E) Error
Exposure Java 2013, APCS Edition Chapter 11 Test Page 4 Updated: 05-16-13
Objective 2 – ArrayList and Java Primitive Types
(A) 11
22
33
44
55
(B) 55
(C) 11 22 33 44 55
### (D) [11, 22, 33, 44, 55]
(E) Error
10. Java provides wrapper classes, which create objects that store primitive data types.
Which of the following are Java wrapper classes?
Exposure Java 2013, APCS Edition Chapter 11 Test Page 5 Updated: 05-16-13
11. Which of the following statements correctly uses a wrapper class to store a primitive data type?
import java.util.ArrayList;
int k;
for (k = 1; k <= 10; k++)
numbers.add(new Integer(k));
int sum = 0;
for (k = 0; k < numbers.size(); k++)
{
Integer temp = (Integer) numbers.get(k);
sum += temp.intValue();
}
(A) 5
### (B) 5.5
(C) 10
(D) 50
(E) 55
Exposure Java 2013, APCS Edition Chapter 11 Test Page 6 Updated: 05-16-13
Objective 4 – ArrayList and Generics
15. What is guaranteed by a generic declaration like the one shown below?
Exposure Java 2013, APCS Edition Chapter 11 Test Page 7 Updated: 05-16-13
16. Consider the following program segment.
class Person
{
private String name;
private int age;
Which of the following statements correctly declares a generic ArrayList object of Person objects?
Exposure Java 2013, APCS Edition Chapter 11 Test Page 8 Updated: 05-16-13
18. What is the output of the following program segment?
(D) Error
(B) 1000
Kathy Coleman
(D) Error
Exposure Java 2013, APCS Edition Chapter 11 Test Page 9 Updated: 05-16-13
20. What is the output of the following program segment?
(B) 1000
Kathy Coleman
Which of the following statements display all the elements in the names array?
(A) System.out.println(names);
Exposure Java 2013, APCS Edition Chapter 11 Test Page 10 Updated: 05-16-13
22. Assume the following declaration.
names1.add("Isolde");
names1.add("John");
names1.add("Greg");
names1.add("Maria");
names1.add("Heidi");
Which of the following statements describes the correct execution of the program segment?
Exposure Java 2013, APCS Edition Chapter 11 Test Page 11 Updated: 05-16-13
24. Consider the following program segment.
Exposure Java 2013, APCS Edition Chapter 11 Test Page 12 Updated: 05-16-13
26. Consider the following program segment.
Which of the following code segments copies the elements from list1 into list2 ?
(A) I only
(B) II only
(C) III only
(D) I and II only
### (E) I and III only
Exposure Java 2013, APCS Edition Chapter 11 Test Page 13 Updated: 05-16-13
28. Assume that mammals is correctly declared as a two-dimensional dynamic array of String elements.
Which of the following will display every element of the mammals array?
II. System.out.println(mammals);
(A) I only
(B) I and II only
(C) I and III only
(D) II and III only
### (E) I, II and III
Exposure Java 2013, APCS Edition Chapter 11 Test Page 14 Updated: 05-16-13