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 331–340 of 357
  1. 331
  2. 332
  3. 333
  4. 334
  5. 335
  6. 336
  7. 337
  8. 338
  9. 339
  10. 340

Question 331

Multiple choice Boolean Expressions
The boolean variables outer and inner are initialized. The required behavior is: print A only when both are true; print B whenever outer is false; otherwise…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 332

Multiple choice Boolean Expressions
What happens when this code is compiled and run as part of an otherwise valid method? The displayed indentation does not…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 333

Multiple choice Boolean Expressions
Both versions use the same initialized boolean values p and q. Which statement about their outputs is correct? // Version I if (p) if (q)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 334

Multiple choice Boolean Expressions
The int variables left and right and boolean enabled are initialized. Which condition is true…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 335

Multiple choice Boolean Expressions
Each version starts with int x = 1 and the same boolean values p and q. Which condition completes the rewrite so that both the final x and complete output are…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 336

Multiple choice Boolean Expressions
The boolean variables a and b are initialized. Which condition is true exactly when visits finishes…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 337

Multiple choice Boolean Expressions
The boolean variables p, q and r are initialized and are not changed. Which condition completes the rewrite so that its output matches the original for every…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 338

Multiple choice Boolean Expressions
The int x is initialized and none of the bodies changes it. A programmer changes the second and third if statements to else if. Which statement…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 339

Multiple choice Boolean Expressions
Each version begins with the same int x from -3 through 6 inclusive. Which condition completes the rewrite so that final x is preserved for every allowed…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 340

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 331 of 357
Page 34 of 36