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. for (int j = 0; j < 10; j++) { for (int k = 10; k > j; k--) {…
Sign up now. It's free!
See the full question with its answer and worked solution.
Consider the following code segment. boolean b1 = true; boolean b2 = true; int x = 7; while (b1 || b2) { if (x > 4) {…
Sign up now. It's free!
See the full question with its answer and worked solution.
Which of the following three code segments will produce the same output? I. int i = 1; while (i < 12) { System.out.print(i + " "); i *= 2; } II. for…
Sign up now. It's free!
See the full question with its answer and worked solution.
Consider the following code segment. double count = 6.0; for (int num = 0; num < 5; num++) { if (count != 0 && num /…
Sign up now. It's free!
See the full question with its answer and worked solution.
Consider the following code segment. double tabulate = 100.0; int repeat = 1; while (tabulate > 20) { tabulate = tabulate…
Sign up now. It's free!
See the full question with its answer and worked solution.
Refer to the following program segment. for (int n = 50; n > 0; n = n / 2)…
Sign up now. It's free!
See the full question with its answer and worked solution.
Consider the following static method. public static int compute(int n) { for (int i = 1; i < 4; i++) n *= n; return n; } Which of…
Sign up now. It's free!
See the full question with its answer and worked solution.
Consider the following code segment. int num1 = value1, num2 = value2, num3 = value3; while (num1 > num2 || num1 > num3) { /* body of loop */ } You may…
Sign up now. It's free!
See the full question with its answer and worked solution.
Consider the following code segment. for (int n = 25; n >= 0; n /= 2)…
Sign up now. It's free!
See the full question with its answer and worked solution.
Consider the following loop, where n is some positive integer. for (int i = 0; i < n; i += 2) { if (/* test */) /* perform some…
Sign up now. It's free!
See the full question with its answer and worked solution.
Page 9 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.