Verityprep
Question Bank · Unit 4

AP® Computer Science A Data Collections Multiple Choice Questions

Work through AP Computer Science A multiple-choice questions on Data Collections, then check each answer against a worked solution.

Free · no sign-up Open questions need no account. Sign up or log in to open the rest.

Subtopic: Arrays Clear filter

Questions 261–270 of 300
  1. 261
  2. 262
  3. 263
  4. 264
  5. 265
  6. 266
  7. 267
  8. 268
  9. 269
  10. 270

Question 261

Multiple choice Arrays
private int n; public boolean check(int[ ] arr) { boolean theCheck = true; for (int k = 0; k < n - 1; k++) { if (arr[k] >= arr[k+1]) theCheck =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 262

Multiple choice Arrays
private int n; public boolean check(int[ ] arr) { boolean theCheck = true; for (int k = 0; k < n - 1; k++) { if (arr[k] >= arr[k+1]) theCheck =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 263

Multiple choice Arrays
Consider the following incomplete method that is intended to determine if the corresponding elements of two parallel arrays are equal. // precondition:…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 264

Multiple choice Arrays
Consider the following code segment: String[] data = {"3.5", "2.1", "4.4", "1.2"}; double sum = 0.0; for (int i = 0; i < data.length; i++) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 265

Multiple choice Arrays
Consider the following method: public static int[] doubleArray(int[] arr) { int[] result = new int[arr.length]; for (int i = 0; i <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 266

Multiple choice Arrays
What is the output of the following code? int[] arr = {5, 3, 8, 1, 9}; int result = arr[0]; for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 267

Multiple choice Arrays
What is the output of the following code? int[] arr = {3, 1, 4, 1, 5, 9, 2, 6}; int count = 0; for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 268

Multiple choice Arrays
The following method is supposed to shift all elements of an array one position to the left, with the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 269

Multiple choice Arrays
What does arr contain after the following code? int[] arr = {5, 2, 8, 1, 9, 3}; for (int i = 0; i <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 270

Multiple choice Arrays

What is the content of arr after executing the following?

int[] arr = {1, 2, 3, 4, 5, 6, 7, 8};
int n = arr.length;
for (int i = 0; i < n / 2; i++) {
    int temp = arr[i];
    arr[i] = arr[n / 2 + i];
    arr[n / 2 + i] = temp;
}
Pick an answer, then check it. The solution opens in a window.
Question 261 of 300
Page 27 of 30