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 241–250 of 740
  1. 241
  2. 242
  3. 243
  4. 244
  5. 245
  6. 246
  7. 247
  8. 248
  9. 249
  10. 250

Question 241

Multiple choice Iteration
What are the values of a and b after the for loop finishes? int a = 10; int b…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 242

Multiple choice Boolean Expressions
Consider the following method: public static void sample(int num1, int num2) { int result = 99; if (num1 == num2) { result = 0; } else if (num1 > num2) { result…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 243

Multiple choice Iteration
Given the following code segment: for (int j = 1; j <= 5; j++) { for (int k = 1; k <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 244

Multiple choice Boolean Expressions
Consider the following method: public void sample(int num1, int num2) { int result = 99; if (num1 == num2) { result = 0; } else if (num1 > num2) { result = 1; }…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 245

Multiple choice Iteration
Given the following code segment: int t = 13; while (t < 29) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 246

Multiple choice Iteration
Given the following code segment: int a = 5, b = 2, temp; for (int i = 1; i <= 4; i++) { temp…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 247

Multiple choice Iteration
Consider the following code segment: for(int i = 0; i < 3; i++) { for(int j = 1; j <= 7;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 248

Multiple choice Boolean Expressions
Consider the following Java method, conditionTest, which takes two integer arguments, num1 and num2, and prints a letter based on their values: public static…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 249

Multiple choice Iteration
Consider the following code segment: for (int i = 0; i = 1; j--)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 250

Multiple choice Boolean Expressions
Consider the following Boolean expression where a and b are…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 241 of 740
Page 25 of 74