Verityprep
Question Bank

AP® Computer Science A Multiple Choice Questions

Work through AP Computer Science A multiple-choice questions unit by unit, 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 1,041–1,050 of 2,811
  1. 1041
  2. 1042
  3. 1043
  4. 1044
  5. 1045
  6. 1046
  7. 1047
  8. 1048
  9. 1049
  10. 1050

Question 1041

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment.
int age = 25;
if (age >= 18 && age < 65)
{
    System.out.print("adult ");
}
if (age < 18 || age >= 65)
{
    System.out.print("special ");
}
if (!(age >= 18) || !(age < 65))
{
    System.out.print("edge ");
}
What is printed when the code segment executes?
Pick an answer, then check it. The solution opens in a window.

Question 1042

Multiple choice Unit 2: Selection and Iteration
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 1043

Multiple choice Unit 2: Selection and 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 1044

Multiple choice Unit 2: Selection and 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 1045

Multiple choice Unit 2: Selection and Iteration
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 1046

Multiple choice Unit 2: Selection and Iteration
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 1047

Multiple choice Unit 2: Selection and Iteration
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 1048

Multiple choice Unit 2: Selection and 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 1049

Multiple choice Unit 2: Selection and 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 1050

Multiple choice Unit 2: Selection and Iteration
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 1,041 of 2,811
Page 105 of 282