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 121–130 of 740
  1. 121
  2. 122
  3. 123
  4. 124
  5. 125
  6. 126
  7. 127
  8. 128
  9. 129
  10. 130

Question 121

Free response Boolean Expressions
Given 2 ints, a and b, return their sum. However, "teen" values in the range 13..19 inclusive, are extra lucky. So if either value is a teen,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 122

Free response Boolean Expressions
Your cell phone rings. Return true if you should answer it. Normally you answer, except in the morning you only answer if it is your mom calling. In all cases,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 123

Free response Boolean Expressions
We are having a party with amounts of tea and candy. Return the int outcome of the party encoded as 0=bad, 1=good, or 2=great. A party is good (1) if both tea…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 124

Free response Boolean Expressions
Given a string str, if the string starts with "f" return "Fizz". If the string ends with "b" return "Buzz". If both the "f" and "b" conditions are true, return…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 125

Free response Boolean Expressions
Given an int n, return the string form of the number followed by "!". So the int 6 yields "6!". Except if the number is divisible by 3 use "Fizz" instead of the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 126

Free response Boolean Expressions
Given three ints, a b c, return true if it is possible to add two of the ints to get the third. twoAsOne(1, 2, 3) → true…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 127

Free response Boolean Expressions
Given three ints, a b c, return true if b is greater than a, and c is greater than b. However, with the exception that if "bOk" is true, b does not need to be…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 128

Free response Boolean Expressions
Given three ints, a b c, return true if they are in strict increasing order, such as 2 5 11, or 5 6 7, but not 6 5 7 or 5 5 7. However, with the exception that…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 129

Free response Boolean Expressions
Given three ints, a b c, return true if two or more of them have the same rightmost digit. The ints are non-negative. Note: the % "mod" operator computes the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 130

Free response Boolean Expressions
Given three ints, a b c, return true if one of them is 10 or more less than one of the others. lessBy10(1, 7, 11) → true…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 121 of 740
Page 13 of 74