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 561–570 of 692
  1. 561
  2. 562
  3. 563
  4. 564
  5. 565
  6. 566
  7. 567
  8. 568
  9. 569
  10. 570

Question 561

Multiple choice Boolean Expressions
The boolean variables p and q are initialized. Which condition completes the rewrite while preserving the complete output for every input? // Original if (p) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 562

Multiple choice Boolean Expressions
Each version starts with int total = 0 and the same boolean values p and q. Which condition identifies exactly when the outputs differ but the final totals are…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 563

Multiple choice Boolean Expressions
The int bounds low and high are each from -10 through 10 inclusive and remain unchanged. The int x may have any value. Which condition is true exactly when…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 564

Multiple choice Boolean Expressions
The boolean variables p and q are initialized and int x starts at 0. Insert one offered statement at the comment. Which insertion guarantees that…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 565

Multiple choice Boolean Expressions
The required behavior is to print A for p && q, B for !p && q, and nothing otherwise. p and q are boolean. Which…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 566

Multiple choice Boolean Expressions
For int n, result should be -1 for negative inputs and 1 otherwise. Which inputs are handled incorrectly by…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 567

Multiple choice Boolean Expressions
Each implementation is run separately with the same nonnegative int x. What is the smallest x for which all three complete outputs are different from one…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 568

Multiple choice Boolean Expressions
The boolean variables p and q are initialized. In Version I, moving the else to the outer if produces Version II. Which pair of tests exercises both directions…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 569

Multiple choice Boolean Expressions
The int variables a and b each initially lie from 0 through 4 inclusive. Which condition, evaluated before the code…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 570

Multiple choice Boolean Expressions
The boolean variables p, q and r are initialized and unchanged. int pick starts at 0. Which replacement…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 561 of 692
Page 57 of 70