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 231–240 of 740
  1. 231
  2. 232
  3. 233
  4. 234
  5. 235
  6. 236
  7. 237
  8. 238
  9. 239
  10. 240

Question 231

Multiple choice Iteration
I. int i = 1; while (i II. for (int i = 0; i < 5; i++) { System.out.print(2*i + 1); } III. for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 232

Multiple choice Boolean Expressions
Consider the following expressions, where x and y are boolean variables with different values: I. (x || y) && (!x ||…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 233

Multiple choice Iteration
Consider the following code segment: int x = <integer value>, y = <another integer value>; while (x > y && x % y != 0) { x -=…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 234

Multiple choice Iteration
What is printed when the following code segment is executed? int sum = 0, d = -1; for (int count =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 235

Multiple choice Boolean Expressions
Consider the following method: private double compute(int x, int y) { double r = 0; if (!(y == 0 || x / y <= 2)) { r = 1 /…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 236

Multiple choice Iteration
Consider the following method: /* * Returns the number of times the digit d occurs in the decimal representation of * Precondition: n and d are non-negative…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 237

Multiple choice Boolean Expressions
When is the following Boolean expression…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 238

Multiple choice Iteration
Which of the following code segments will produce the following output? 1 22 333 4444 Code Segments: I. for (int i = 1; i < 5; i++) { for (int j = i; j > 0;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 239

Multiple choice Iteration
Consider the following code segment: int i = a random number such that 1 <= i <= n; for (int a = 2; a <= i; a++) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 240

Multiple choice Iteration
Consider the following code segment: for (int i = 0; i <= 3; i++) { for (int j = i;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 231 of 740
Page 24 of 74