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: Iteration Clear filter

Questions 11–20 of 376
  1. 11
  2. 12
  3. 13
  4. 14
  5. 15
  6. 16
  7. 17
  8. 18
  9. 19
  10. 20

Question 11

Multiple choice Iteration
Consider the following code segment. int a = 24; int b = 30; while (b != 0) { int r = a % b; a…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 12

Multiple choice Iteration
Consider the following code segments. Which of the code segments above will produce the following output? I. int k = 1; while (k < 20) { if (k % 3 == 1)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 13

Multiple choice Iteration
Consider the following code segment: int p = 5; int q = 2; int sum = 0; while (p <=…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 14

Multiple choice Iteration
Consider the following code segment. for (int k = 0; k < 20; k = k + 1) { if (k % 2 == 1)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 15

Multiple choice Iteration
Consider the following code segment for(int i = 0; i <= 3; i++) { for(int j = 1;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 16

Multiple choice Iteration
Consider the following code segment. for (int k = 0; k < 20; k = k + 1) { if (k % 2 ==…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 17

Multiple choice Iteration
What is the output from the following code segment? for (int j = 1; j…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 18

Multiple choice Iteration
What are the first and last values output by the following code…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 19

Multiple choice Iteration
What are the values of a and b after the for loop finishes? int a = 5, b…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 20

Multiple choice Iteration
Questions refer to the following method. public static int mystery(int n) { int x = 1; int y = 1; // Point A while (n > 2)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 11 of 376
Page 2 of 38