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,011–1,020 of 2,811
  1. 1011
  2. 1012
  3. 1013
  4. 1014
  5. 1015
  6. 1016
  7. 1017
  8. 1018
  9. 1019
  10. 1020

Question 1011

Multiple choice Unit 2: Selection and Iteration
What is printed?
int x = 8;
boolean c1 = (x > 5 && x < 8);
boolean c2 = !(x >= 10) || x == 8;
boolean c3 = (x < 0 || x > 12) && x != 8;
System.out.println(c1 + " " + c2 + " " + c3);
Pick an answer, then check it. The solution opens in a window.

Question 1012

Multiple choice Unit 2: Selection and Iteration
What is printed?
int count = 0;
for (int i = 0; i < 5; i++)
{
    for (int j = i; j < 5; j++)
    {
        count++;
    }
}
System.out.println(count);
Pick an answer, then check it. The solution opens in a window.

Question 1013

Multiple choice Unit 2: Selection and Iteration
Assume a, b, c, and d are properly declared int variables. Which of the following is always equivalent to the expression below?
!(a >= b) || (c == d)
Pick an answer, then check it. The solution opens in a window.

Question 1014

Multiple choice Unit 2: Selection and Iteration
What is printed?
int sum = 0;
for (int k = 2; k <= 20; k += 3)
{
    sum += k;
}
System.out.println(sum);
Pick an answer, then check it. The solution opens in a window.

Question 1015

Multiple choice Unit 2: Selection and Iteration
What is printed?
int a = 4;
int b = 0;
if (b != 0 && a / b > 1)
{
    System.out.print("X ");
}
if (a > 0 || (10 / b) > 0)
{
    System.out.print("Y");
}
Pick an answer, then check it. The solution opens in a window.

Question 1016

Multiple choice Unit 2: Selection and Iteration
What is printed?
int n = 1;
int total = 0;
while (total < 30)
{
    total = total + n;
    n = n + 2;
}
System.out.println(n + " " + total);
Pick an answer, then check it. The solution opens in a window.

Question 1017

Multiple choice Unit 2: Selection and Iteration
Assume x and y are boolean variables that have been properly initialized. Which of the following always evaluates to the same value as the expression below?
!x || y
Pick an answer, then check it. The solution opens in a window.

Question 1018

Multiple choice Unit 2: Selection and Iteration
What is printed?
for (int i = 1; i <= 3; i++)
{
    for (int j = 1; j <= i; j++)
    {
        System.out.print(i + "" + j + " ");
    }
}
System.out.println();
Pick an answer, then check it. The solution opens in a window.

Question 1019

Multiple choice Unit 2: Selection and Iteration
What is printed?
int a = 6, b = 9;
String msg = "";
if (a > 5 && b > 10)
{
    msg = "X";
} else if (a + b >= 15 || a == b)
{
    msg = "Y";
} else if (a > 0)
{
    msg = "Z";
}
System.out.println(msg);
Pick an answer, then check it. The solution opens in a window.

Question 1020

Multiple choice Unit 2: Selection and Iteration
What is printed?
int count = 0;
for (int k = 1; k <= 50; k++)
{
    if (k % 3 == 0 && k % 5 != 0)
    {
        count++;
    }
}
System.out.println(count);
Pick an answer, then check it. The solution opens in a window.
Question 1,011 of 2,811
Page 102 of 282