Verityprep
Question Bank · Unit 2

AP® Computer Science A Selection and Iteration Multiple Choice Questions

Work through AP Computer Science A multiple-choice questions on Selection and Iteration, 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.

Subtopic: Boolean Expressions Clear filter

Questions 121–130 of 316
  1. 121
  2. 122
  3. 123
  4. 124
  5. 125
  6. 126
  7. 127
  8. 128
  9. 129
  10. 130

Question 121

Multiple choice Boolean Expressions
Which of the following boolean expressions is…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 122

Multiple choice Boolean Expressions
What is printed? int x = 15, y = 20, z = 10; String result = ""; if (x > z && y > x) { if (y - x…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 123

Multiple choice Boolean Expressions
What is the result of executing the following code? int x = 0;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 124

Multiple choice Boolean Expressions
What is printed? int a = 5, b = 12; boolean p = !(a > 3 && b < 10); boolean…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 125

Multiple choice Boolean Expressions
Consider this method that analyzes two-digit numbers. public static boolean…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 126

Multiple choice Boolean Expressions

What is printed?

int a = 4, b = 7, c = 10;
boolean p = !(a < b && b < c);
boolean q = !(a < b) || !(b < c);
boolean r = a >= b || b >= c;
System.out.println(p + " " + q + " " + r + " " + (p == q && q == r));
Pick an answer, then check it. The solution opens in a window.

Question 127

Multiple choice Boolean Expressions

What is printed?

int x = 6;
boolean a = x % 2 == 0 && x % 4 == 0;
boolean b = x % 3 == 0 || x % 4 == 0;
boolean c = !(x % 8 == 0) || (x % 2 == 0);
System.out.println(a + " " + b + " " + c);
Pick an answer, then check it. The solution opens in a window.

Question 128

Multiple choice Boolean Expressions

What is printed?

int a = 7, b = 3, c = 5;
int result = 0;
if (a > b + c) {
    result = 1;
} else if (a > b && a > c) {
    if (b + c > a + 1) {
        result = 2;
    } else {
        result = 3;
    }
} else {
    result = 4;
}
System.out.println(result);
Pick an answer, then check it. The solution opens in a window.

Question 129

Multiple choice Boolean Expressions

What is printed?

int a = 0, b = 5, c = 3;
boolean p = (a != 0) && (b / a > 1);
boolean q = (a == 0) || (b / a > 1);
boolean r = (c > b) || (a != 0) && (b > c);
System.out.println(p + " " + q + " " + r);
Pick an answer, then check it. The solution opens in a window.

Question 130

Multiple choice Boolean Expressions

What is printed?

int x = 12;
String label = "";
if (x % 2 == 0 && x % 3 == 0) {
    label = "A";
}
if (x % 4 == 0 && x % 3 == 0) {
    label = label + "B";
}
if (x % 6 == 0) {
    label = label + "C";
} else {
    label = label + "D";
}
System.out.println(label);
Pick an answer, then check it. The solution opens in a window.
Question 121 of 316
Page 13 of 32