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.

Subtopic: Iteration Clear filter

Questions 201–210 of 376
  1. 201
  2. 202
  3. 203
  4. 204
  5. 205
  6. 206
  7. 207
  8. 208
  9. 209
  10. 210

Question 201

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

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 202

Multiple choice Iteration
Consider the following code segment. int n = 12; int step = 0; while (n > 1) { if (n % 2 == 0) n = n / 2;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 203

Multiple choice Iteration
Consider the following code segment. int[] arr = { 2, 4, 6, 8, 10 }; int sum = 0; int i = 1; while (i <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 204

Multiple choice Iteration
Consider the following code segment. int x = 0; int y = 10; while (x < y) { x = x + 2; y =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 205

Multiple choice Iteration
Consider the following code segment, which is intended to remove every even value from nums. ArrayList<Integer> nums = new ArrayList<Integer>(); nums.add(2);…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 206

Multiple choice Iteration
Consider the following code segment. int total = 0; for (int k = 1; k <= 20; k++) { if (k % 2 == 0 && k %…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 207

Multiple choice Iteration
Consider the following code segment.
int n = 128;
int steps = 0;
while (n > 1)
{
    n = n / 2;
    steps = steps + 1;
}
System.out.println(steps);
What is printed when the code segment executes?
Pick an answer, then check it. The solution opens in a window.

Question 208

Multiple choice Iteration
Consider the following code segment. int count = 0; for (int i = 1; i <= 4; i++) { for (int j = i; j…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 209

Multiple choice Iteration
Consider the following code segment. int n = 1; int k = 0; while (n < 50) { n = n * 2; k =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 210

Multiple choice Iteration
Consider the following code segment. int[] arr = {1, 2, 3, 4, 5}; for (int i = 0; i < arr.length / 2; i++) { int temp = arr[i]; arr[i] =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 201 of 376
Page 21 of 38