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.

Subtopic: Boolean Expressions Clear filter

Questions 341–350 of 357
  1. 341
  2. 342
  3. 343
  4. 344
  5. 345
  6. 346
  7. 347
  8. 348
  9. 349
  10. 350

Question 341

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 342

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 343

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 344

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 345

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 346

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 347

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 348

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 349

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 350

Multiple choice Boolean Expressions
The boolean variables p, q and r may have any values. Which list contains all and only the possible complete outputs? Semicolons in the choices separate…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 341 of 357
Page 35 of 36