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 401–410 of 692
  1. 401
  2. 402
  3. 403
  4. 404
  5. 405
  6. 406
  7. 407
  8. 408
  9. 409
  10. 410

Question 401

Multiple choice Boolean Expressions
Suppose a, b, and c are int variables. Which of the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 402

Multiple choice Iteration
Consider the following code segment.
int n = 81;
int count = 0;
while (n > 1)
{
    if (n % 3 == 0)
        n = n / 3;
    else
        n = n - 1;
    count++;
}
What value is stored in count after the loop terminates?
Pick an answer, then check it. The solution opens in a window.

Question 403

Multiple choice Iteration
Consider the following code segment. int value = 3; for (int k = 0; k…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 404

Multiple choice Iteration
Consider the following method.
public static int process(int n)
{
    int result = 0;
    while (n > 0)
    {
        result = result + n % 10;
        n = n / 100;
    }
    return result;
}
What value is returned by process(58364) ?
Pick an answer, then check it. The solution opens in a window.

Question 405

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

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 406

Multiple choice Iteration
Consider the following code segment. int n = 50; int count = 0; while (n > 4) { if (n % 2 ==…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 407

Multiple choice Boolean Expressions
Which of the following is…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 408

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

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 409

Multiple choice Iteration
Consider the following method. public static int mystery(int n) { int count = 0; while (n > 0) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 410

Multiple choice Boolean Expressions
Consider the following declarations. int x = 0; int y = 5; boolean b…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 401 of 692
Page 41 of 70