Question Bank · Unit 2
AP® Computer Science A Selection and Iteration Practice Questions
Work through AP Computer Science A practice 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.
All 740
Multiple choice 692
Free response 48
Consider the code segment if (n == 1) k++; else if (n == 4) k += 4; Suppose that the given segment is rewritten in the form if (/* condition */) /* assignment…
Sign up now. It's free!
See the full question with its answer and worked solution.
Consider the following code snippet: public class Main { public static void main(String[] args) { boolean a = true; boolean…
Sign up now. It's free!
See the full question with its answer and worked solution.
Consider the following code segment: int i = 2; for (int k = 0; k <= 12; k += i) {…
Sign up now. It's free!
See the full question with its answer and worked solution.
Consider the following code segment: int a = 1, b = 2; for (int k = 1; k <= 2; k++) { int oldA = a; a…
Sign up now. It's free!
See the full question with its answer and worked solution.
Assume that the int variables a and b have been properly declared and initialized. For which of the following pairs of values of a and b is the…
Sign up now. It's free!
See the full question with its answer and worked solution.
Consider the following code segment, which is supposed to calculate and print the sum of the numbers from 1 to 20: int count = 0,…
Sign up now. It's free!
See the full question with its answer and worked solution.
Assume that the boolean variables x, y, and z have been properly declared and initialized. Given that x is true, y is true, and…
Sign up now. It's free!
See the full question with its answer and worked solution.
Consider the following code segment. int n = 1, d = 1, s = 1; while (n <= 5) { System.out.print(s +…
Sign up now. It's free!
See the full question with its answer and worked solution.
Assume that the boolean variables a, b, and c have been properly declared and initialized. Which of…
Sign up now. It's free!
See the full question with its answer and worked solution.
Consider the following code segment: int num = 5; while (num >= 0) { num -=…
Sign up now. It's free!
See the full question with its answer and worked solution.
Page 23 of 74
Get your FRQs graded in the Student Portal
In the Verityprep Student Portal, answer the FRQs of AP practice and past exams by typing or uploading a photo. A teacher grades them with that year's official College Board scoring guidelines and gives you an estimated 1–5 score.
Join Verityprep now
AP® and Advanced Placement® are registered trademarks of the College Board, which is not affiliated with, and does not endorse, Verityprep. Names are used for identification purposes only.