Verityprep
Question Bank

AP® Computer Science A Practice Questions

Work through AP Computer Science A practice questions unit by unit, 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.

Questions 2,551–2,560 of 3,140
  1. 2551
  2. 2552
  3. 2553
  4. 2554
  5. 2555
  6. 2556
  7. 2557
  8. 2558
  9. 2559
  10. 2560

Question 2551

Multiple choice Unit 4: Data Collections
Consider the following code segment: ArrayList<String> cities = new ArrayList<String>(); cities.add("Atlanta"); cities.add("Boston");…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2552

Multiple choice Unit 4: Data Collections
Consider the following method: public String filter(String str, String pattern) { int pos = str.indexOf(pattern); if (pos == -1) return str; else return…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2553

Multiple choice Unit 4: Data Collections
Consider the following code segment: int[] arr = {4, 3, 2, 1, 0}; for (int k = 1; k < arr.length; k++) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2554

Multiple choice Unit 4: Data Collections
Consider the following method: public int countSomething(int[] arr) { int m = arr[0]; int count = 1; for (int k = 1; k < arr.length; k++) { int a =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2555

Multiple choice Unit 4: Data Collections
Consider the following method: public void change(double[] nums, int n) { for (int k = 0; k < n; k++) { nums[k] = 5.4; } n = 2; } What will be stored…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2556

Multiple choice Unit 4: Data Collections
Consider the following code segment: for (int r = 1;r < mat.length;r++) { for (int c = 1;c < mat[0].length;c++) { if ((r + c) % 2 == 0) mat[r][c] = 2 * mat[r -…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2557

Multiple choice Unit 4: Data Collections
What happens when the size of an ArrayList<Integer>…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2558

Multiple choice Unit 4: Data Collections
Suppose an array arr contains 127 different random values arranged in ascending order, and the most efficient searching…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2559

Multiple choice Unit 4: Data Collections
Suppose ArrayList<Integer> numbers and ArrayList<String> names are created as follows: ArrayList<Integer> numbers = new ArrayList<Integer>(); Integer x = 1;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2560

Multiple choice Unit 4: Data Collections
What is the result when the following code segment is executed? Object[] nums = {null, null, null}; nums[0] = new…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2,551 of 3,140
Page 256 of 314