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 21–30 of 740
  1. 21
  2. 22
  3. 23
  4. 24
  5. 25
  6. 26
  7. 27
  8. 28
  9. 29
  10. 30

Question 21

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 22

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 23

Multiple choice Boolean Expressions
Consider the following code segment. double a = 1.1; double b = 1.2; if ((a + b) * (a - b) != (a * a) - (b * b)) { System.out.println("Mathematical error!");…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 24

Multiple choice Boolean Expressions
Which of the following code segments is equivalent to…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 25

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 26

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 27

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 28

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 29

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 30

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 21 of 740
Page 3 of 74