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.

Subtopic: Boolean Expressions Clear filter

Questions 301–310 of 316
  1. 301
  2. 302
  3. 303
  4. 304
  5. 305
  6. 306
  7. 307
  8. 308
  9. 309
  10. 310

Question 301

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 302

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 303

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 304

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 305

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 306

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 307

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 308

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 309

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 310

Multiple choice Boolean Expressions
What is printed as a result of executing the following code segment? int score = 85; String g = ""; if (score >= 90) g +=…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 301 of 316
Page 31 of 32