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.

Questions 181–190 of 692
  1. 181
  2. 182
  3. 183
  4. 184
  5. 185
  6. 186
  7. 187
  8. 188
  9. 189
  10. 190

Question 181

Multiple choice Iteration
Consider the following code segment. for (int n = 25; n >= 0; n /= 2)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 182

Multiple choice Iteration
Consider the following loop, where n is some positive integer. for (int i = 0; i < n; i += 2) { if (/* test */) /* perform some…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 183

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 184

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 185

Multiple choice Iteration
Consider the following code segment: int i = 2; for (int k = 0; k <= 12; k += i) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 186

Multiple choice Iteration
Consider the following code segment: int a = 1, b = 2; for (int k = 1; k <= 2; k++) { int oldA = a; a…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 187

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 188

Multiple choice Iteration
Consider the following code segment, which is supposed to calculate and print the sum of the numbers from 1 to 20: int count = 0,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 189

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 190

Multiple choice Iteration
Consider the following code segment. int n = 1, d = 1, s = 1; while (n <= 5) { System.out.print(s +…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 181 of 692
Page 19 of 70