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,101–1,110 of 2,811
  1. 1101
  2. 1102
  3. 1103
  4. 1104
  5. 1105
  6. 1106
  7. 1107
  8. 1108
  9. 1109
  10. 1110

Question 1101

Multiple choice Unit 2: Selection and Iteration

Consider the following code segment.

int x = 4;
int y = 6;

if (x + y > 10)
{
    x = y - x;
}
else
{
    y = x + y;
}

if (x * 2 >= y)
{
    y = y - x;
}
else
{
    x = x + y;
}

System.out.println(x + " " + y);

What is printed?

Pick an answer, then check it. The solution opens in a window.

Question 1102

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment. String s = "banana"; int count = 0; while (s.indexOf("na") >=…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1103

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment. int result = 1; for (int i = 2; i < 7; i = i + 2) { result =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1104

Multiple choice Unit 2: Selection and Iteration

Consider the following code segment.

boolean a = true;
boolean b = false;
boolean c = true;

boolean value = !(a && b) && (b || c) && !(a && !c);

What value is stored in value?

Pick an answer, then check it. The solution opens in a window.

Question 1105

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment. int n = 19; int total = 0; while (n > 0) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1106

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment. String s = "aaaa"; int n = 0; while (s.length() > 1…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1107

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment. int count = 0; for (int r = 0; r < 3; r++) { for (int c = r;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1108

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment. int count = 0; for (int r = 0; r < 4; r++) { for (int c = 0;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1109

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment. int x = 4; int y = 9; int z = 2; boolean…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1110

Multiple choice Unit 2: Selection and Iteration
Consider the following code segment. int a = 5; int b = 2; int c = 7; boolean…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1,101 of 2,811
Page 111 of 282