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 681–690 of 692
  1. 681
  2. 682
  3. 683
  4. 684
  5. 685
  6. 686
  7. 687
  8. 688
  9. 689
  10. 690

Question 681

Multiple choice Iteration
For every int n from 0 through 6 inclusive, which statement in the replacement loop preserves the final value of sum? Each version starts with int sum = 0;. //…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 682

Multiple choice Iteration
Each version begins with int a = 3; and int b = 2;. For every int n from 0 through 8 inclusive, which replacement body preserves…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 683

Multiple choice Iteration
Which replacement makes steps equal to the number of integer divisions by 3 needed for a positive val to become 0? The original val…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 684

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

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 685

Multiple choice Iteration
Each version starts with int result = 2;. For how many int values of n from 0 through 4 inclusive do the versions finish with the same value of…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 686

Multiple choice Iteration
The code below is intended to sum all positive even integers less than or equal to n. Which…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 687

Multiple choice Iteration
For every int n from 0 through 10 inclusive, which replacement leaves sum equal to the original…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 688

Multiple choice Iteration
Which replacement produces the same final values of both sum and k as the original? Each version…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 689

Multiple choice Iteration
The int variables low and high satisfy 1 <= low <= high <= 20. Which replacement makes hasDiv4 equal to true exactly when at least one multiple…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 690

Multiple choice Iteration
Consider the following code segment, where n is a random integer such that 1 <= n <= 15. What is the minimum number of…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 681 of 692
Page 69 of 70