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 361–370 of 692
  1. 361
  2. 362
  3. 363
  4. 364
  5. 365
  6. 366
  7. 367
  8. 368
  9. 369
  10. 370

Question 361

Multiple choice Boolean Expressions
Consider the boolean expression below, where a, b, and c are int variables. !(a <= b)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 362

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 363

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 364

Multiple choice Boolean Expressions
Consider the following method.
public static String g(int n)
{
    if (n < 10)
    {
        return "" + n;
    }
    return (n % 10) + g(n / 10);
}
What is returned by the call g(1423)?
Pick an answer, then check it. The solution opens in a window.

Question 365

Multiple choice Boolean Expressions
Consider the following boolean expression, where a and b are int variables. !(a >= 10…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 366

Multiple choice Boolean Expressions
Consider the following method, which increments a counter and returns false. private int count = 0; public boolean check() { count++; return false; } Consider…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 367

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 368

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 369

Multiple choice Boolean Expressions
Consider the following boolean expression, where x is an int variable. (x > 0 && x < 10)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 370

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 361 of 692
Page 37 of 70