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 991–1,000 of 2,811
  1. 991
  2. 992
  3. 993
  4. 994
  5. 995
  6. 996
  7. 997
  8. 998
  9. 999
  10. 1000

Question 991

Multiple choice Unit 2: Selection and Iteration

What is printed?

int count = 0;
for (int i = 1; i <= 20; i++) {
    boolean divisible = false;
    for (int j = 2; j * j <= i; j++) {
        if (i % j == 0) {
            divisible = true;
        }
    }
    if (!divisible && i > 1) {
        count++;
    }
}
System.out.println(count);
Pick an answer, then check it. The solution opens in a window.

Question 992

Multiple choice Unit 2: Selection and Iteration
int x = (int)(Math.random() * 10); while (x < 5) { System.out.print(x + " "); x =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 993

Multiple choice Unit 2: Selection and Iteration
Consider the following code. int x = (int)(Math.random() * 5); while (x > 0) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 994

Multiple choice Unit 2: Selection and Iteration
Consider the following code. int x = 0; while (x < 5) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 995

Multiple choice Unit 2: Selection and Iteration
Consider the following code. int x = 4; int y = 1; while…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 996

Multiple choice Unit 2: Selection and Iteration
public static String classify(int score) { String result = ""; if (score >= 90) result = "A"; if…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 997

Multiple choice Unit 2: Selection and Iteration
public static int mystery(int x) { int y = 1; while (x > 1 && y <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 998

Multiple choice Unit 2: Selection and Iteration
public static boolean check(int num) { return num > 0 && num % 2…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 999

Multiple choice Unit 2: Selection and Iteration
public static String evaluate(int temperature, boolean isRaining) { String result; if (temperature > 30 && !isRaining) { result = "beach"; }…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1000

Multiple choice Unit 2: Selection and Iteration
Consider the following boolean expression: !(x >…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 991 of 2,811
Page 100 of 282