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 161–170 of 740
  1. 161
  2. 162
  3. 163
  4. 164
  5. 165
  6. 166
  7. 167
  8. 168
  9. 169
  10. 170

Question 161

Multiple choice Boolean Expressions
What will the output be for the following poorly formatted program segment, if the input value for num is 22? int num = call to a…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 162

Multiple choice Boolean Expressions
What values are stored in x and y after execution of the following program segment? int x = 30, y =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 163

Multiple choice Boolean Expressions
Which of the following will evaluate to true only…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 164

Multiple choice Boolean Expressions
Assume that a and b are integers. The boolean expression !(a…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 165

Multiple choice Boolean Expressions
Given that a, b, and c are integers, consider the boolean expression (a < b) || !((c…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 166

Multiple choice Boolean Expressions
In the following code segment, you may assume that a, b, and n are all type int. if (a != b && n / (a - b) >…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 167

Multiple choice Iteration
Given that n and count are both of type int, which statement is true about the following code segments? I for (count = 1;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 168

Multiple choice Iteration
The following fragment intends that a user will enter a list of positive integers at the keyboard and terminate the list with a sentinel. int value = 0; final…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 169

Multiple choice Iteration
Consider this code segment. int x = 10, y = 0; while (x > 5) { y = 3; while (y < x) { y *= 2; if (y % x == 1)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 170

Multiple choice Iteration
What output will be produced by this code segment? (Ignore spacing.) for (int i = 5; i >=…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 161 of 740
Page 17 of 74