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 301–310 of 383
  1. 301
  2. 302
  3. 303
  4. 304
  5. 305
  6. 306
  7. 307
  8. 308
  9. 309
  10. 310

Question 301

Multiple choice Iteration
What is printed? int count = 0; for (int r = 1; r <= 4; r++) { for (int c =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 302

Multiple choice Iteration
The original loop prints six coordinate pairs. Which replacement for the comment inside the single loop makes it print exactly the same sequence? // Original…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 303

Multiple choice Iteration
Which replacement produces the same final values of both total and i as the original? Each version…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 304

Multiple choice Iteration
For every int n from 0 through 10 inclusive, which replacement leaves total equal to the original…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 305

Multiple choice Iteration
The code is intended to sum all positive odd integers less than or equal to n. Which…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 306

Multiple choice Iteration
For every int n from 1 through 6 inclusive, the code should count all executions of the inner body. Which single edit fixes…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 307

Multiple choice Iteration
Which statement describes the code? int x = 2;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 308

Multiple choice Iteration
Which replacement makes count equal to the number of integer divisions by 2 needed for a positive x to become 0? The original x…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 309

Multiple choice Iteration
Which replacement lets the loop terminate normally with d equal to 0, without throwing…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 310

Multiple choice Iteration
What is printed? Notice the semicolon immediately after the for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 301 of 383
Page 31 of 39