Verityprep
Question Bank · Unit 4

AP® Computer Science A Data Collections Practice Questions

Work through AP Computer Science A practice 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 131–140 of 341
  1. 131
  2. 132
  3. 133
  4. 134
  5. 135
  6. 136
  7. 137
  8. 138
  9. 139
  10. 140

Question 131

Multiple choice Arrays
Consider the following code segment. int[] arr = {4, 2, 2, 3, 1}; int num = 0; for (int k = 0;k…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 132

Multiple choice Arrays
Consider a method to determine whether two arrays have the same length and same values stored in the same order. public static boolean haveSameContents(int[]…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 133

Multiple choice Arrays
Consider the following code segment. int[] items = {10, 20, 30, 40, 50, 60}; int sum = 0; for (int k = items.length;k > items.length / 2;k--) { sum…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 134

Multiple choice Arrays
Consider the following code segment, which is intended to print true if all elements of the integer array arr are equal in value and false otherwise. Assume arr…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 135

Multiple choice Arrays
Consider the following incomplete method, which is intended to reverse the elements in an array. public static void reverse(int[] values) { for (int k = 0;/ *…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 136

Multiple choice Arrays
Which initializes an int array with four zero elements? I: int[] arr={0,0,0,0};…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 137

Multiple choice Arrays
Assume location has been declared. The segment should locate the first negative…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 138

Multiple choice Arrays
What occurs for a nonempty int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 139

Multiple choice Arrays
arr1 initially contains [0,6,0,4,0,0,2]. What does…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 140

Multiple choice Arrays
Assume k≥2 and arr.length>k. What is the maximum…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 131 of 341
Page 14 of 35