Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Document preview thumbnail
Vista previa 2 fuera de 10 páginas
Examen

AP Computer Science A Unit 7 Progress Check: MCQ (ANSWERED)

Document preview thumbnail
Vista previa 2 fuera de 10 páginas

Consider the following statement, which is intended to create an ArrayList named a to store only elements of type Thing. Assume that the Thing class has been properly defined and includes a no-parameter constructor. ArrayListThing a = /* missing code */; Which of the following can be used to replace /* missing code */ so that the statement works as intended? - Correct Answer B. new ArrayListThing() Consider the following statement, which is intended to create an ArrayList named numbers that can be used to store Integer values. ArrayListInteger numbers = /* missing code */; Which of the following can be used to replace /* missing code */ so that the statement works as intended? new ArrayList() new ArrayListInteger new ArrayListInteger() - Correct Answer C. I and III only Consider the following statement, which is intended to create an ArrayList named arrList to store elements only of type String. /* missing code */ = new ArrayListString(); Which of the following can be used to replace /* missing code */ so that the statement works as intended? - Correct Answer E. ArrayListString arrList Consider the following code segment. ArrayListInteger nums = new ArrayList(); (3); (2); (1); (0); (0, 4); (3, 2); e(3); (2, 0); Which of the following represents the contents of nums after the code segment has been executed? - Correct Answer D. [4, 3, 0, 2, 0]

Vista previa del contenido

AP Computer Science A Unit 7 Progress Check:
MCQ (ANSWERED)
Consider the following statement, which is intended to create an ArrayList named a to store only
elements of type Thing. Assume that the Thing class has been properly defined and includes a no-
parameter constructor.

ArrayList<Thing> a = /* missing code */;

Which of the following can be used to replace /* missing code */ so that the statement works as
intended? - Correct Answer B. new ArrayList<Thing>()



Consider the following statement, which is intended to create an ArrayList named numbers that can be
used to store Integer values.

ArrayList<Integer> numbers = /* missing code */;

Which of the following can be used to replace /* missing code */ so that the statement works as
intended?

new ArrayList()

new ArrayList<Integer>

new ArrayList<Integer>() - Correct Answer C. I and III only



Consider the following statement, which is intended to create an ArrayList named arrList to store
elements only of type String.

/* missing code */ = new ArrayList<String>();

Which of the following can be used to replace /* missing code */ so that the statement works as
intended? - Correct Answer E. ArrayList<String> arrList



Consider the following code segment.

ArrayList<Integer> nums = new ArrayList<>();



nums.add(3);

nums.add(2);

nums.add(1);

, nums.add(0);

nums.add(0, 4);

nums.set(3, 2);

nums.remove(3);

nums.add(2, 0);

Which of the following represents the contents of nums after the code segment has been executed? -
Correct Answer D. [4, 3, 0, 2, 0]



Consider the following code segment.

ArrayList<String> syllables = new ArrayList<String>();



syllables.add("LA");

syllables.add(0, "DI");

syllables.set(1, "TU");

syllables.add("DA");

syllables.add(2, syllables.get(0));

syllables.remove(1);



System.out.println(syllables.toString());

What is printed as a result of executing the code segment? - Correct Answer B. [DI, DI, DA]



Consider the following code segment.

ArrayList<Integer> vals = new ArrayList<Integer>();

vals.add(vals.size(), vals.size());

vals.add(vals.size() - 1, vals.size() + 1);

vals.add(vals.size() - 2, vals.size() + 2);

System.out.println(vals.toString());

What is printed as a result of executing the code segment? - Correct Answer E. [4, 2, 0]

Información del documento

Subido en
6 de agosto de 2024
Número de páginas
10
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$7.49

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
Lydiah247
2.2
(5)
Vendido
33
Seguidores
10
Artículos
2865
Última venta
4 meses hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes