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 421–430 of 692
  1. 421
  2. 422
  3. 423
  4. 424
  5. 425
  6. 426
  7. 427
  8. 428
  9. 429
  10. 430

Question 421

Multiple choice 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 422

Multiple choice 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 423

Multiple choice Boolean Expressions

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 424

Multiple choice 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 425

Multiple choice 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 426

Multiple choice 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 427

Multiple choice 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 428

Multiple choice Boolean Expressions
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 429

Multiple choice Boolean Expressions
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 430

Multiple choice Boolean Expressions
What is printed by the following code segment? int n = 6; if (n % 2 == 0)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 421 of 692
Page 43 of 70