Verityprep
Question Bank · Unit 2

AP® Computer Science A Selection and Iteration Practice Questions

Work through AP Computer Science A practice 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 357
  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
Consider the code segment if (n == 1) k++; else if (n == 4) k += 4; Suppose that the given segment is rewritten in the form if (/* condition */) /* assignment…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 132

Multiple choice Boolean Expressions
Consider the following code snippet: public class Main { public static void main(String[] args) { boolean a = true; boolean…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 133

Multiple choice Boolean Expressions
Assume that the int variables a and b have been properly declared and initialized. For which of the following pairs of values of a and b is the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 134

Multiple choice Boolean Expressions
Assume that the boolean variables x, y, and z have been properly declared and initialized. Given that x is true, y is true, and…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 135

Multiple choice Boolean Expressions
Assume that the boolean variables a, b, and c have been properly declared and initialized. Which of…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 136

Multiple choice Boolean Expressions
Consider the following expressions, where x and y are boolean variables with different values: I. (x || y) && (!x ||…

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 method: private double compute(int x, int y) { double r = 0; if (!(y == 0 || x / y <= 2)) { r = 1 /…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 138

Multiple choice Boolean Expressions
When is the following Boolean expression…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 139

Multiple choice Boolean Expressions
Consider the following method: public static void sample(int num1, int num2) { int result = 99; if (num1 == num2) { result = 0; } else if (num1 > num2) { result…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 140

Multiple choice Boolean Expressions
Consider the following method: public void sample(int num1, int num2) { int result = 99; if (num1 == num2) { result = 0; } else if (num1 > num2) { result = 1; }…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 131 of 357
Page 14 of 36