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 661–670 of 1,222
  1. 661
  2. 662
  3. 663
  4. 664
  5. 665
  6. 666
  7. 667
  8. 668
  9. 669
  10. 670

Question 661

Multiple choice Arraylists
The method addStars is intended to append "*" at the end of each string in the ArrayList<String> words. Which of the following implementations of addStars will…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 662

Multiple choice Arrays
Consider the following method: public boolean examine(String[] letters) { int count = 0; for (String letter1 : letters) { for (String letter2 : letters) { if…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 663

Multiple choice Arraylists
public class APTestResult { private String subject; private int score; public int getScore() { return score; } // constructor and other methods not shown }…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 664

Multiple choice Arrays
What is printed when the following code segment is executed? String[] xy = {"X", "Y"};…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 665

Multiple choice 2D Arrays
Suppose m is a two-dimensional array of size 4 by 4, with all its elements initialized to zeros. The method fill is defined as follows: public void…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 666

Multiple choice Sorting And Searching
Consider the following method: /* * Returns the number of zeros in s. * Precondition: s.length() = 31; s consists of several * '0's followed by several '1's *…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 667

Multiple choice Recursion
Consider the following method: public String encrypt(String word) { int pos = word.length() / 2; if (pos >= 1) { word =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 668

Multiple choice Arrays
Consider the following code segment. int[] nums = new int[8]; nums[0] = 0; int n = 1; while (n < nums.length) { int k; for (k = n; k < 2 *…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 669

Multiple choice Arraylists
What is printed when the following code segment is executed? int[] factors = {2, 3, 5}; ArrayList<Integer> products = new ArrayList<Integer>(); products.add(1);…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 670

Multiple choice Sorting And Searching
Suppose names is an array of String objects: String[] names = {"Dan", "Ada", "Claire", "Evan", "Boris"}; public class SortX { public static void sort(String[]…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 661 of 1,222
Page 67 of 123