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.

Questions 361–370 of 740
  1. 361
  2. 362
  3. 363
  4. 364
  5. 365
  6. 366
  7. 367
  8. 368
  9. 369
  10. 370

Question 361

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 362

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 363

Multiple choice Boolean Expressions
public static boolean isSpecial(int num) { return num…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 364

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 365

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 366

Multiple choice Boolean Expressions
public static int findMax(int num1, int num2, int num3) { int max = num1; if (num2 > num1) max = num2; if (num3 >…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 367

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 368

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 369

Free response Iteration
The FestivalManager class contains methods used for a game booth at a school festival. public class FestivalManager { / * * Returns a random integer from 1…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 370

Multiple choice Boolean Expressions
What is printed?
int x = 4, y = 10, z = 4;
boolean a = !(x > y) && !(z == x);
boolean b = (x < y) || (z > x);
boolean c = !(x == z || y < x);
System.out.println(a + " " + b + " " + c);
Pick an answer, then check it. The solution opens in a window.
Question 361 of 740
Page 37 of 74