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
Subtopic: Iteration
Clear filter
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.
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.
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.
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.
I. int i = 1; while (i II. for (int i = 0; i < 5; i++) { System.out.print(2*i + 1); } III. for…
Sign up now. It's free!
See the full question with its answer and worked solution.
Consider the following code segment: int x = <integer value>, y = <another integer value>; while (x > y && x % y != 0) { x -=…
Sign up now. It's free!
See the full question with its answer and worked solution.
What is printed when the following code segment is executed? int sum = 0, d = -1; for (int count =…
Sign up now. It's free!
See the full question with its answer and worked solution.
Consider the following method: /* * Returns the number of times the digit d occurs in the decimal representation of * Precondition: n and d are non-negative…
Sign up now. It's free!
See the full question with its answer and worked solution.
Which of the following code segments will produce the following output? 1 22 333 4444 Code Segments: I. for (int i = 1; i < 5; i++) { for (int j = i; j > 0;…
Sign up now. It's free!
See the full question with its answer and worked solution.
Page 10 of 39
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.