Verityprep
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.

Subtopic: Iteration Clear filter

Questions 141–150 of 383
  1. 141
  2. 142
  3. 143
  4. 144
  5. 145
  6. 146
  7. 147
  8. 148
  9. 149
  10. 150

Question 141

Free response Iteration
A teacher wants to analyze student-submitted text. You will write methods for a TextAnalyzer class. The class has a single instance variable: private String…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 142

Multiple choice Iteration
The following code is meant to find the GCD of two positive integers using Euclid's algorithm. Which correctly completes…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 143

Multiple choice Iteration
What does the following method return for n = 7? public static boolean check(int n) { if (n < 2)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 144

Multiple choice Iteration
A method with parameter int n must return true if and only if n is a perfect square,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 145

Multiple choice Iteration
What is the output of the following code? int x = 100; while (x > 1) { if (x %…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 146

Multiple choice Iteration
Consider the following method: public static String build(int n) { String s = ""; for (int i = 1; i <= n; i++) { for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 147

Multiple choice Iteration
What is printed when the following code executes? int n = 256; int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 148

Multiple choice Iteration
What is the value of result after the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 149

Multiple choice Iteration
What is printed by the following code? int x = 1; while (x < 30)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 150

Multiple choice Iteration
What is the value of sum? int sum = 0; for (int i = 1; i…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 141 of 383
Page 15 of 39