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 181–190 of 740
  1. 181
  2. 182
  3. 183
  4. 184
  5. 185
  6. 186
  7. 187
  8. 188
  9. 189
  10. 190

Question 181

Multiple choice Iteration
Consider the following code segment. int n = 0 ; while ( n < 20) { System.out.print(n % 4 + " " ) ; if (…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 182

Multiple choice Iteration
Consider the following method. public int someMethod(int val) { for (int i = 2; i < 7; i++) { if…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 183

Multiple choice Boolean Expressions
Consider the following code segment. int num1 = 2; int num2 = 13; int result = 4; if ((num1 < 5) && (num2 < 5)) result = num1 - num2; else if ((num1 ==…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 184

Multiple choice Boolean Expressions
Assume that k, m, and n have been declared and correctly initialized with int values. Consider the following statement.…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 185

Multiple choice Iteration
Consider the following code segment. for (int h = 2; h <= 6; h += 2) { for (int k = 30; k > 0; k -= 10) { System.out.print(h + k + " "); } } Consider these…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 186

Multiple choice Boolean Expressions
Assume that a, b, and c have been declared and correctly initialized with int values. Consider the following…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 187

Multiple choice Boolean Expressions
Consider the following method. public int pathways(int n) { int ans; if (n < -5) ans = 1; else if (n < 0) ans = 2; else if…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 188

Multiple choice Boolean Expressions
A resort wants to recommend activities for its guests, based on the temperature (degrees F) as follows: 76° and above go swimming 61°–75° go hiking 46°–60° go…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 189

Multiple choice Boolean Expressions
A resort wants to recommend activities for its guests, based on the temperature (degrees F) as follows: 76° and above go swimming 61°–75° go hiking 46°–60° go…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 190

Multiple choice Iteration
Consider the following code segment. for (int h = 5; h >= 0; h = h - 2) { for (int k = 0; k < 3; k++) { if ((h…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 181 of 740
Page 19 of 74