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 961–970 of 2,811
  1. 961
  2. 962
  3. 963
  4. 964
  5. 965
  6. 966
  7. 967
  8. 968
  9. 969
  10. 970

Question 961

Multiple choice Unit 2: Selection and Iteration
What is printed? int count = 0; for (int i = 1; i <= 50; i++) { if…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 962

Multiple choice Unit 2: Selection and Iteration
What is printed? int sum = 0; for (int i = 1; i <= 3; i++) { for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 963

Multiple choice Unit 2: Selection and Iteration
The following code generates a well-known sequence. What is printed? int a = 1, b = 1; for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 964

Multiple choice Unit 2: Selection and Iteration
Consider this method that analyzes two-digit numbers. public static boolean…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 965

Multiple choice Unit 2: Selection and Iteration
What is printed? int x = 1; for (int i = 0; i <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 966

Multiple choice Unit 2: Selection and Iteration

What is printed?

int product = 1;
for (int i = 1; i <= 6; i++) {
    if (i % 2 == 0) {
        product *= i;
    }
}
System.out.println(product);
Pick an answer, then check it. The solution opens in a window.

Question 967

Multiple choice Unit 2: Selection and Iteration

What is printed?

int a = 4, b = 7, c = 10;
boolean p = !(a < b && b < c);
boolean q = !(a < b) || !(b < c);
boolean r = a >= b || b >= c;
System.out.println(p + " " + q + " " + r + " " + (p == q && q == r));
Pick an answer, then check it. The solution opens in a window.

Question 968

Multiple choice Unit 2: Selection and Iteration

What is printed?

int sum = 0;
for (int i = 1; i <= 4; i++) {
    for (int j = i; j <= 4; j++) {
        sum += i * j;
    }
}
System.out.println(sum);
Pick an answer, then check it. The solution opens in a window.

Question 969

Multiple choice Unit 2: Selection and Iteration

What is printed?

String s = "aAbBcCdD";
String result = "";
for (int i = 0; i < s.length(); i++) {
    String ch = s.substring(i, i + 1);
    if (ch.compareTo("a") >= 0 && ch.compareTo("z") <= 0) {
        result += ch;
    }
}
System.out.println(result);
Pick an answer, then check it. The solution opens in a window.

Question 970

Multiple choice Unit 2: Selection and Iteration

What is printed?

int x = 6;
boolean a = x % 2 == 0 && x % 4 == 0;
boolean b = x % 3 == 0 || x % 4 == 0;
boolean c = !(x % 8 == 0) || (x % 2 == 0);
System.out.println(a + " " + b + " " + c);
Pick an answer, then check it. The solution opens in a window.
Question 961 of 2,811
Page 97 of 282