• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 122 pages
Exam (elaborations)

AP Computer Science Exam with Verified Answers

Document preview thumbnail
Preview 4 out of 122 pages

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

Content preview

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++)
{

Document information

Uploaded on
October 5, 2025
Number of pages
122
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$23.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Sold
12
Followers
0
Items
12590
Last sold
3 months ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions