Verityprep
Question Bank · Unit 2

AP® Computer Science A Selection and Iteration Multiple Choice Questions

Work through AP Computer Science A multiple-choice 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 376
  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
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 182

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 183

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 184

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 185

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 186

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 187

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 188

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 189

Multiple choice Iteration
What is printed?
int n = 100;
int count = 0;
while (n > 1)
{
    n = n / 2;
    count++;
}
System.out.println(count);
Pick an answer, then check it. The solution opens in a window.

Question 190

Multiple choice Iteration
What is printed?
int count = 0;
for (int i = 0; i < 5; i++)
{
    for (int j = i; j < 5; j++)
    {
        count++;
    }
}
System.out.println(count);
Pick an answer, then check it. The solution opens in a window.
Question 181 of 376
Page 19 of 38