Verityprep
Question Bank · Unit 2

AP® Computer Science A Selection and Iteration Multiple Choice Questions

Work through AP Computer Science A multiple-choice 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 692
  1. 141
  2. 142
  3. 143
  4. 144
  5. 145
  6. 146
  7. 147
  8. 148
  9. 149
  10. 150

Question 141

Multiple choice Iteration
Which of the following code segments will print exactly eight "$" symbols? I. for (int i = 0; i < 8; i++) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 142

Multiple choice Iteration
Consider the following code segment. int a = /* value supplied within program */ int b = /* value supplied within program */ if (/* missing condition */) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 143

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 144

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 145

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 146

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 147

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 148

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 149

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 150

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 141 of 692
Page 15 of 70