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 301–310 of 357
  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 boolean variables p, q and r are initialized. Which offered initial triple (p, q, r) makes all…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 302

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 303

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 304

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 305

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 306

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 307

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 308

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 309

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 310

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 301 of 357
Page 31 of 36