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,061–1,070 of 2,811
  1. 1061
  2. 1062
  3. 1063
  4. 1064
  5. 1065
  6. 1066
  7. 1067
  8. 1068
  9. 1069
  10. 1070

Question 1061

Multiple choice Unit 2: Selection and Iteration
Consider the boolean expression below, where a, b, and c are boolean variables.
!(a && (b || !c))
Which of the following is logically equivalent to the expression above?
Pick an answer, then check it. The solution opens in a window.

Question 1062

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment.
int n = 100;
int steps = 0;
while (n > 1)
{
    if (n % 2 == 0)
    {
        n = n / 2;
    }
    else
    {
        n = n - 1;
    }
    steps = steps + 1;
}
System.out.println(steps);
What is printed when the code segment executes?
Pick an answer, then check it. The solution opens in a window.

Question 1063

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment. String s = ""; for (int r = 1; r <= 3; r++) { for (int c = 0; c < r;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1064

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

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1065

Multiple choice Unit 2: Selection and Iteration
Consider the following method.
public static String rate(int n)
{
    if (n < 0 || n > 100)
    {
        return "invalid";
    }
    if (n < 25)
    {
        return "low";
    }
    if (n < 75)
    {
        return "mid";
    }
    return "high";
}
For how many integer values of n in the range \(0 \leq n \leq 100\) does rate(n) return "mid"?
Pick an answer, then check it. The solution opens in a window.

Question 1066

Multiple choice Unit 2: Selection and Iteration
Consider the following expression, where a and b are int variables. (a > 0 && b > 0) || (a < 0…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1067

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment. int n = 1; int total = 0; while (n < 100) { total = total + n; if (n < 10)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1068

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment, where arr is a non-null int array (possibly empty).
int i = 0;
while (i < arr.length && arr[i] != 0)
{
    i = i + 1;
}
Which of the following statements about the loop is true for every valid value of arr?
Pick an answer, then check it. The solution opens in a window.

Question 1069

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment. int[] a = {5, 2, 8, 1, 9, 3}; for (int i = 0; i < a.length - 1; i++) { if (a[i] >…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1070

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment. ArrayList<Integer> list = new ArrayList<Integer>(); list.add(3); list.add(6); list.add(3); list.add(3); list.add(9);…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1,061 of 2,811
Page 107 of 282