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 3,101–3,110 of 3,140
  1. 3101
  2. 3102
  3. 3103
  4. 3104
  5. 3105
  6. 3106
  7. 3107
  8. 3108
  9. 3109
  10. 3110

Question 3101

Multiple choice Unit 4: Data Collections
Suppose a standard binary search is used to locate 12 in the following sorted array.…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 3102

Multiple choice Unit 4: Data Collections
A text file contains the following integers, separated by spaces. 6 2 9 3 8 Assume sc is a properly constructed Scanner that reads the file. What is printed by…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 3103

Multiple choice Unit 4: Data Collections
Consider the following class. public class ScoreEntry { private String name; private int score; public ScoreEntry(String n, int s) { name = n; score = s; }…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 3104

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

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 3105

Free response Unit 4: Data Collections
Information about players in a school league is stored in Player objects. public class Player { private String name; private int points; private boolean active;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 3106

Multiple choice Unit 4: Data Collections
Consider the following code segment. int[] a = {2, 4, 6}; int[] b = a; b[1] = a[0] +…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 3107

Multiple choice Unit 4: Data Collections
Consider the following code segment. ArrayList<Integer> nums = new ArrayList<Integer>(); nums.add(2); nums.add(4); nums.add(3); nums.add(5);…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 3108

Multiple choice Unit 4: Data Collections

Consider the following code segment.

int[][] grid = {
    {1, 2, 3},
    {4, 5, 6},
    {7, 8, 9}
};

int sum = 0;

for (int r = 0; r < grid.length; r++)
{
    for (int c = 0; c < grid[0].length; c++)
    {
        if (r + c == 2)
        {
            sum = sum + grid[r][c];
        }
        else if (r == c)
        {
            sum = sum - grid[r][c];
        }
    }
}

What is the value of sum after the loops?

Pick an answer, then check it. The solution opens in a window.

Question 3109

Multiple choice Unit 4: Data Collections
Consider the following recursive method. public static int recur(int n) { if (n < 3) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 3110

Multiple choice Unit 4: Data Collections
Selection sort is used on the array {6, 2, 8, 1,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 3,101 of 3,140
Page 311 of 314