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 181–190 of 383
  1. 181
  2. 182
  3. 183
  4. 184
  5. 185
  6. 186
  7. 187
  8. 188
  9. 189
  10. 190

Question 181

Multiple choice Iteration
int x = (int)(Math.random() * 10); while (x < 5) { System.out.print(x + " "); x =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 182

Multiple choice Iteration
Consider the following code. int x = (int)(Math.random() * 5); while (x > 0) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 183

Multiple choice Iteration
Consider the following code. int x = 0; while (x < 5) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 184

Multiple choice Iteration
public static int mystery(int x) { int y = 1; while (x > 1 && y <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 185

Multiple choice Iteration
public static int mystery(int value) { int result = 0; while (value > 0) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 186

Multiple choice Iteration
public static int countDown(int start) { int count = 0; for (int i =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 187

Multiple choice Iteration
public static int process(int limit) { int total = 0; for (int i = 1;i <=…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 188

Multiple choice Iteration
public static String buildPattern(int rows) { String result = ""; for (int i = 1;i <= rows;i++) { for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 189

Multiple choice Iteration
public static int trace(int num) { int result = 0; while (num > 1) { if (num % 2 == 0)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 190

Multiple choice Iteration
public static String encrypt(String word) { String result = ""; for (int i = 0;i < word.length();i++) { if (i % 2 == 0) { result + =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 181 of 383
Page 19 of 39