100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Unit 8 - AP Computer Science - AP Classroom Exam Questions and Answers $10.49   Add to cart

Exam (elaborations)

Unit 8 - AP Computer Science - AP Classroom Exam Questions and Answers

 8 views  0 purchase
  • Course
  • AP Computer Science
  • Institution
  • AP Computer Science

Unit 8 - AP Computer Science - AP Classroom Exam

Preview 2 out of 5  pages

  • July 30, 2024
  • 5
  • 2023/2024
  • Exam (elaborations)
  • Questions & answers
  • AP Computer Science
  • AP Computer Science
avatar-seller
millyphilip
Unit 8 - AP Computer Science - AP Classroom Exam
A two-dimensional array myArray is to be created with the following contents.
{{0, 0, 3},
{0, 0, 0},
{7, 0, 0}}
Which of the following code segments can be used to correctly create and initialize myArray ? int myArray[][] = new int[3 [3]; myArray[0][2] = 3;
myArray[2][0] = 7;
int myArray[][] = new int[3][3];myArray[0][2] = 7;myArray[2][0] = 3;
int myArray[][] = {{0, 0, 3}, {0, 0, 0}, {7, 0, 0}}; - Answer -D. I and III
Consider the following code segment, which is intended to create and initialize the two-
dimensional (2D) integer array num so that columns with an even index will contain only
even integers and columns with an odd index will contain only odd integers.
int[][] num = /* missing code */;
Which of the following initializer lists could replace /* missing code */ so that the code segment will work as intended? - Answer -{{0, 1, 2}, {4, 5, 6}, {8, 3, 6}}
Consider the following code segment, which is intended to display "cat".
String[][] keyboard = {{"q", "w", "e", "r", "t"},
{"a", "s", "d", "f", "g"},
{"z", "x", "c", "v", "b"}};
System.out.println(/* missing expression */);
Which of the following can replace /* missing expression */ so that the code segment works as intended? - Answer -keyboard[2][2] + keyboard[1][0] + keyboard[0][4]
Consider the following code segment, where twoD is a two-dimensional (2D) String array. The code segment is intended to display "JAVA".
System.out.print(twoD[2][1]);
System.out.print(twoD[3][2]);
System.out.print(twoD[1][1]); Which of the following code segments properly declares and initializes twoD so that the code segment works as intended? - Answer -String[][] twoD = {{"V", "AV", "J"}, {"JA", "VA", "A"},
{"JA", "J", "JAV"}, {"AV", "V", "A"}};
int[][] multi = new int[4][4];
for (int rows = 0; rows < 4; rows++)
{
for (int cols = 0; cols < 4; cols++)
{
if (cols == 0)
{
multi[rows][cols] = 0;
}
else if (cols == 1)
{
multi[rows][cols] = 1;
}
else if (cols == 2)
{
multi[rows][cols] = 2;
}
if ((rows % 2 == 0) && (cols % 2 == 0))
{
if ((rows >= 2) && (cols <= 2))
{
multi[rows][cols] = 9;
}
}
}
}
As a result of executing the code segment, how many elements in the two-dimensional (2D) array multi will store the value 9 ? - Answer -C. 2
Consider the following code segment.
int[][] mat = {{10, 15, 20, 25},
{30, 35, 40, 45},
{50, 55, 60, 65}};
for (int[] row : mat)
{
for (int j = 0; j < row.length; j += 2)
{
System.out.print(row[j] + " ");
}
System.out.println();

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller millyphilip. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $10.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

73314 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$10.49
  • (0)
  Add to cart