Verityprep
Question Bank

AP® Computer Science A Multiple Choice Questions

Work through AP Computer Science A multiple-choice 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 1,051–1,060 of 2,811
  1. 1051
  2. 1052
  3. 1053
  4. 1054
  5. 1055
  6. 1056
  7. 1057
  8. 1058
  9. 1059
  10. 1060

Question 1051

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment. int count = 0; for (int i = 1; i <= 4; i++) { for (int j = i; j…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1052

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment. int n = 1; int k = 0; while (n < 50) { n = n * 2; k =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1053

Multiple choice Unit 2: Selection and Iteration
Consider the following boolean expression, where a, b, and c are int variables. a > 0…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1054

Multiple choice Unit 2: Selection and Iteration
Consider the following method. public static String grade(int score) { String result = ""; if (score >= 90) { result = "A"; }…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1055

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment. int[] arr = {1, 2, 3, 4, 5}; for (int i = 0; i < arr.length / 2; i++) { int temp = arr[i]; arr[i] =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1056

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment.
ArrayList<Integer> nums = new ArrayList<Integer>();
nums.add(2);
nums.add(4);
nums.add(4);
nums.add(6);
nums.add(4);
for (int i = 0; i < nums.size(); i++)
{
    if (nums.get(i) == 4)
    {
        nums.remove(i);
    }
}
System.out.println(nums);
What is printed when the code segment executes?
Pick an answer, then check it. The solution opens in a window.

Question 1057

Multiple choice Unit 2: Selection and Iteration
Consider the following method. public static int count(int n) { if (n < 1) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1058

Multiple choice Unit 2: Selection and Iteration
Consider the following class. public class Logger { private int calls; public Logger() { calls = 0; } public boolean ping() { calls = calls + 1; return true; }…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1059

Multiple choice Unit 2: Selection and Iteration
Consider the following method. public static String tier(int score) { if (score >= 90) { return "gold"; } else if (score >=…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1060

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment. int sum = 0; for (int i = 5; i <= 20; i = i + 3) { if (i % 2…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1,051 of 2,811
Page 106 of 282