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.

Questions 631–640 of 1,222
  1. 631
  2. 632
  3. 633
  4. 634
  5. 635
  6. 636
  7. 637
  8. 638
  9. 639
  10. 640

Question 631

Multiple choice Arraylists
Consider the following class. public class BankAccount { private int balance; public BankAccount() { balance = 0; } public BankAccount(int amt) { balance = amt;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 632

Multiple choice Arraylists
Consider the following code segment. ArrayList<Integer> numbers = new ArrayList<Integer>(); numbers.add(0); numbers.add(1); for (int k = 1; k <= 3; k++) { int n…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 633

Multiple choice Arraylists
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 634

Multiple choice Recursion
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 635

Multiple choice Arrays
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 636

Multiple choice Arrays
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 637

Multiple choice Arrays
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 638

Multiple choice 2D Arrays
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 639

Multiple choice Arraylists
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 640

Multiple choice Sorting And Searching
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 631 of 1,222
Page 64 of 123