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 21–30 of 341
  1. 21
  2. 22
  3. 23
  4. 24
  5. 25
  6. 26
  7. 27
  8. 28
  9. 29
  10. 30

Question 21

Multiple choice Arrays
Consider the following incomplete method that is intended to return an array that contains the contents of its first array parameter followed by the contents of…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 22

Multiple choice Arrays
Consider the following code segment. int[] arr = {1, 2, 3, 4, 5, 6, 7}; for (int k = 3; k < arr.length - 1; k++)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 23

Multiple choice Arrays
Consider the following method. public static void arrayMethod(int nums[]) { int j = 0; int k = nums.length - 1; while (j < k) { int x =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 24

Multiple choice Arrays
Assume that the array arr has been defined and initialized as follows. int[] arr = /* initial values for the array */ ; Which…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 25

Multiple choice Arrays
Consider the following method. public void mystery(int[] data) { for (int k = 0; k < data.length - 1; k++) data[k + 1] = data[k] + data[k + 1]; } The following…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 26

Multiple choice Arrays
What is the output of the following program? public class SayHello { public void run() { String stringArray[] =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 27

Multiple choice Arrays
What value will be held in mysteryNumber when this code finishes running? int mysteryNumber = 0; String[] mysteryArray =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 28

Multiple choice Arrays
What will the Array gameBoard contain after this code runs? int WIDTH = 3; int HEIGHT = 3; String[] gameBoard = new String[WIDTH * HEIGHT]; for(int m = 0; m <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 29

Multiple choice Arrays
Given the following values of arr and the mystery method, what will the values of arr be after you execute: mystery()? private…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 30

Multiple choice Arrays
The following codes are intended to add 5 to each item in the array. I. int[] numbers = {1, 2, 3, 4}; for (int i = 0;i <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 21 of 341
Page 3 of 35