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.

Questions 141–150 of 740
  1. 141
  2. 142
  3. 143
  4. 144
  5. 145
  6. 146
  7. 147
  8. 148
  9. 149
  10. 150

Question 141

Free response Boolean Expressions
Given 3 int values, a b c, return their sum. However, if any of the values is a teen -- in the range 13..19 inclusive -- then that value counts as 0, except 15…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 142

Free response Boolean Expressions
For this problem, we'll round an int value up to the next multiple of 10 if its rightmost digit is 5 or more, so 15 rounds up to 20. Alternately, round down to…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 143

Free response Boolean Expressions
Given three ints, a b c, return true if one of b or c is "close" (differing from a by at most 1), while the other is "far", differing from both other values by…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 144

Free response Boolean Expressions
Given 2 int values greater than 0, return whichever value is nearest to 21 without going over. Return 0 if they both go over.…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 145

Free response Boolean Expressions
Given three ints, a b c, one of them is small, one is medium and one is large. Return true if the three values are evenly spaced, so the difference between…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 146

Free response Boolean Expressions
We want make a package of goal kilos of chocolate. We have small bars (1 kilo each) and big bars (5 kilos each). Return the number of small bars to use,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 147

Multiple choice Boolean Expressions
Vehicles are classified based on their total interior volume. The classify method is intended to return a vehicle classification String value based on total…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 148

Multiple choice Boolean Expressions
Which of the following best describes the value of…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 149

Multiple choice Iteration
Consider the following code segment. int val = 48; int div = 6; while ((val % 2 == 0) && div > 0) { if (val %…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 150

Multiple choice Boolean Expressions
Consider the following code segment. int x = / * some integer value * /; int y = / * some integer value * /; if (x > y && x % 2 == 0) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 141 of 740
Page 15 of 74