• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 4 fuera de 122 páginas
Examen

AP Computer Science Exam with Verified Answers

Document preview thumbnail
Vista previa 4 fuera de 122 páginas

A rectangular puzzle exists with all pieces being identically-sized squares. The main part of the puzzle has a total of 600 pieces and each row of this main part of the puzzle is 30 pieces wide. Additionally, there is a border of artistic icons completely surrounding this main puzzle area, and this border is exactly one piece wide, with each piece of the border being the same size as a main puzzle piece. Finally, at the bottom of the puzzle is one additional row of square pieces that spells out the title of the puzzle. The puzzle is composed of all the before-mentioned pieces, each piece being square and the same size. The PuzzlePiece class is defined as follows: public class PuzzlePiece { private Image image; // Image represented by this piece private int row; // row where this piece goes private int col; // col where this piece goes public PuzzlePiece(Image i, int r, int c) { // Implementation not shown } - D public class Puzzle

Vista previa del contenido

AP Computer Science Exam with
Verified Answers
A rectangular puzzle exists with all pieces being identically-sized squares. The main part of the
puzzle has a total of 600 pieces and each row of this main part of the puzzle is 30 pieces wide.
Additionally, there is a border of artistic icons completely surrounding this main puzzle area,
and this border is exactly one piece wide, with each piece of the border being the same size as a
main puzzle piece. Finally, at the bottom of the puzzle is one additional row of square pieces
that spells out the title of the puzzle.
The puzzle is composed of all the before-mentioned pieces, each piece being square and the
same size. The PuzzlePiece class is defined as follows:


public class PuzzlePiece
{
private Image image; // Image represented by this piece
private int row; // row where this piece goes
private int col; // col where this piece goes
public PuzzlePiece(Image i, int r, int c)
{
// Implementation not shown

} - ✔✔D

public class Puzzle
{
private PuzzlePiece[][] puzzle = new PuzzlePiece[23][32];
// other instance variables and methods not shown
}


Consider the following code.

,public static void main(String args[])
{
int numArray[][]={{3,5,7},{2,4,6},{9,8,7},{6,5,4}};
if (numArray.length==4)
{
for (int i=0; i<numArray[0].length; i++)
{
System.out.print(numArray[i][2]);
}
}
else
{
for(int i=2; i>-1; i--)
{
System.out.print(numArray[2][i]);
}
}
}


---


What is printed as a result of executing the code?


---


A

,767
B
OutOfBoundsException
C
548
D
987
E

246 - ✔✔A

767


Consider the following code segment.


int[][] heights = new int[3][6];
heights[0][0] = 10;
heights[1][0] = 20;
heights[2][0] = 30;
double total = 0;
int count = 0;
for (int r=0; r < heights.length; r++)
{
for (int c=0; c < heights[r].length; c++)
{
total += heights[r][c]; count++;
}
}

, System.out.println((int) (total/count) + ", " + (int) (total/heights.length) + ", " + (int)
(total/heights[0].length));


---


Which of the following is the output printed to the console after this segment of code is
executed?


---


A
20, 20, 10
B
3, 3, 3
C
20, 20, 20
D
10, 10, 10
E

3, 20, 10 - ✔✔E

3, 20, 10


Consider the following method.


public static void print2DimArray(int[][] nums)
{
for (int i=0; i<nums.length; i++)
{

Información del documento

Subido en
5 de octubre de 2025
Número de páginas
122
Escrito en
2025/2026
Tipo
Examen
Contiene
Preguntas y respuestas
$23.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.
Vendido
12
Seguidores
0
Artículos
12590
Última venta
3 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