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 131–140 of 316
  1. 131
  2. 132
  3. 133
  4. 134
  5. 135
  6. 136
  7. 137
  8. 138
  9. 139
  10. 140

Question 131

Multiple choice Boolean Expressions

What is printed?

int score = 78;
String grade = "";
if (score >= 90) {
    grade = "A";
} else if (score >= 80) {
    grade = "B";
} else if (score >= 70) {
    grade = "C";
} else {
    grade = "F";
}
int bonus = score % 10;
if (bonus >= 5) {
    grade = grade + "+";
}
System.out.println(grade + " " + bonus);
Pick an answer, then check it. The solution opens in a window.

Question 132

Multiple choice Boolean Expressions
What is printed?

int x = 5, y = 10; boolean p = !(x > 3 && y < 15); boolean q = x <= 3 || y >= 15; boolean r = !(x > 3) || !(y < 15); System.out.println(p + " " + (p == q) + " " + (q == r));
Pick an answer, then check it. The solution opens in a window.

Question 133

Multiple choice Boolean Expressions
Consider the following code. int x = 4; int y = 1; while…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 134

Multiple choice Boolean Expressions
public static String classify(int score) { String result = ""; if (score >= 90) result = "A"; if…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 135

Multiple choice Boolean Expressions
public static boolean check(int num) { return num > 0 && num % 2…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 136

Multiple choice Boolean Expressions
public static String evaluate(int temperature, boolean isRaining) { String result; if (temperature > 30 && !isRaining) { result = "beach"; }…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 137

Multiple choice Boolean Expressions
Consider the following boolean expression: !(x >…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 138

Multiple choice Boolean Expressions
public static boolean isSpecial(int num) { return num…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 139

Multiple choice Boolean Expressions
public static int findMax(int num1, int num2, int num3) { int max = num1; if (num2 > num1) max = num2; if (num3 >…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 140

Multiple choice Boolean Expressions
What is printed?
int x = 4, y = 10, z = 4;
boolean a = !(x > y) && !(z == x);
boolean b = (x < y) || (z > x);
boolean c = !(x == z || y < x);
System.out.println(a + " " + b + " " + c);
Pick an answer, then check it. The solution opens in a window.
Question 131 of 316
Page 14 of 32