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 331–340 of 376
  1. 331
  2. 332
  3. 333
  4. 334
  5. 335
  6. 336
  7. 337
  8. 338
  9. 339
  10. 340

Question 331

Multiple choice Iteration
What is printed? int total = 0; for (int row = 1; row <= 3; row++) { for (int col = 1; col <=…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 332

Multiple choice Iteration
Version II moves only limit -= row to the start of the outer body, before the inner loop. Each version starts with count = 0 and limit = 5. What are the final…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 333

Multiple choice Iteration
Which output is produced? Spaces inside a line are significant. for (int row = 0; row < 3; row++) { for (int col = 0; col < 5; col++) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 334

Multiple choice Iteration
Which replacement for the condition produces the required four-line output shown in the comment? Leading spaces are significant. /* Required output: * ** ***…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 335

Multiple choice Iteration
Which expression produces the required centered shape shown in the comment? Leading spaces are significant. /* Required output: * *** ***** */ for (int row = 1;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 336

Multiple choice Iteration
Which replacement for the condition produces the required output shown in the comment? /* Required output: *-*- -*-* *-*- */ for (int row = 0; row < 3;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 337

Multiple choice Iteration
Which output is produced? for (int row = 1; row <= 3; row++) { for (int col = 1; col <= 7; col++) { if (col…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 338

Multiple choice Iteration
Which single edit produces the required output shown in the comment, with no extra blank lines? /* Required output: ** **** ****** */…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 339

Multiple choice Iteration
Version I uses row == 0 || col == 0 as the condition. Version II uses row == 0 || col == n - 1. Which offered nonnegative int n is the smallest size for which…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 340

Multiple choice Iteration
For every int n from 0 through 8 inclusive, the loop should leave total equal to n * n. Which…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 331 of 376
Page 34 of 38