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 111–120 of 740
  1. 111
  2. 112
  3. 113
  4. 114
  5. 115
  6. 116
  7. 117
  8. 118
  9. 119
  10. 120

Question 111

Free response Boolean Expressions
You are driving a little too fast, and a police officer stops you. Write code to compute the result, encoded as an int value: 0=no ticket, 1=small ticket, 2=big…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 112

Free response Boolean Expressions
Given 2 ints, a and b, return their sum. However, sums in the range 10..19 inclusive, are forbidden, so in that case just return 20.…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 113

Free response Boolean Expressions
Given a day of the week encoded as 0=Sun, 1=Mon, 2=Tue, ...6=Sat, and a boolean indicating if we are on vacation, return a string of the form "7:00" indicating…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 114

Free response Boolean Expressions
The number 6 is a truly great number. Given two int values, a and b, return true if either one is 6. Or if their sum or difference is 6. Note: the function…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 115

Free response Boolean Expressions
Given a number n, return true if n is in the range 1..10, inclusive. Unless outsideMode is true, in which case return true if the number is less or equal to 1,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 116

Free response Boolean Expressions
We'll say a number is special if it is a multiple of 11 or if it is one more than a multiple of 11. Return true if the given non-negative number is special. Use…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 117

Free response Boolean Expressions
Return true if the given non-negative number is 1 or 2 more than a multiple of 20. See also: Introduction to Mod…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 118

Free response Boolean Expressions
Return true if the given non-negative number is a multiple of 3 or 5, but not both. Use the % "mod" operator -- see…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 119

Free response Boolean Expressions
Return true if the given non-negative number is 1 or 2 less than a multiple of 20. So for example 38 and 39 return true, but 40 returns false. See…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 120

Free response Boolean Expressions
Given a non-negative number num, return true if num is within 2 of a multiple of 10. Note: (a % b) is the remainder of…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 111 of 740
Page 12 of 74