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 571–580 of 740
  1. 571
  2. 572
  3. 573
  4. 574
  5. 575
  6. 576
  7. 577
  8. 578
  9. 579
  10. 580

Question 571

Multiple choice Boolean Expressions
The int variable n may be from 0 through 10 inclusive. Each proposed set is run as separate tests, resetting n each time. Which set executes…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 572

Multiple choice Boolean Expressions
For a nonnegative int value, the required route is 1 for 0–4, 2 for 5–9, and 3 for 10 or above. Which offered pair consists of two inputs that both…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 573

Multiple choice Boolean Expressions
Each version starts with the same int x from 0 through 12 inclusive. Which replacement for the comment makes the rewritten version produce the same final x as…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 574

Multiple choice Boolean Expressions
The intended condition is true exactly when the int n is from 3 through 7 inclusive. Two faulty implementations are shown. Which pair of test inputs detects a…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 575

Multiple choice Boolean Expressions
Each test starts with an int x from 0 through 10 inclusive. Which set of four initial values makes the code print each of A, B, C and D at least once across the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 576

Multiple choice Boolean Expressions
Each implementation is run separately with an initialized int x. A pair of inputs produces a two-character output sequence for each implementation, in the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 577

Multiple choice Boolean Expressions
The int free is from 0 through 8 inclusive, the int requested is from 1 through 4 inclusive, and priority is boolean. Which condition, evaluated before the code…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 578

Multiple choice Boolean Expressions
What is printed? int x = 12; if (x > 0) { System.out.print("A"); } if (x…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 579

Multiple choice Boolean Expressions
What is printed? int n = 16; if (n % 2 == 0) { System.out.print("TWO"); } else if (n % 4…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 580

Multiple choice Boolean Expressions
Each version starts with int tokens = 3. What are the final values for Version I and Version II, respectively? // Version I if (tokens > 0) { tokens -= 1; } if…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 571 of 740
Page 58 of 74