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.

Questions 211–220 of 740
  1. 211
  2. 212
  3. 213
  4. 214
  5. 215
  6. 216
  7. 217
  8. 218
  9. 219
  10. 220

Question 211

Multiple choice Iteration
Which of the following three code segments will produce the same output? I. int i = 1; while (i < 12) { System.out.print(i + " "); i *= 2; } II. for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 212

Multiple choice Iteration
Consider the following code segment. double count = 6.0; for (int num = 0; num < 5; num++) { if (count != 0 && num /…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 213

Multiple choice Iteration
Consider the following code segment. double tabulate = 100.0; int repeat = 1; while (tabulate > 20) { tabulate = tabulate…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 214

Multiple choice Boolean Expressions
If a, b, and c are integers, which of the following conditions is sufficient…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 215

Multiple choice Boolean Expressions
Consider the following code segment. int num = 0, score = 10; if (num != 0 && score / num >…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 216

Multiple choice Iteration
Refer to the following program segment. for (int n = 50; n > 0; n = n / 2)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 217

Multiple choice Iteration
Consider the following static method. public static int compute(int n) { for (int i = 1; i < 4; i++) n *= n; return n; } Which of…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 218

Multiple choice Iteration
Consider the following code segment. int num1 = value1, num2 = value2, num3 = value3; while (num1 > num2 || num1 > num3) { /* body of loop */ } You may…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 219

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 220

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 211 of 740
Page 22 of 74