AP Computer Science A Unit 4 Section 2 (For Loops)

AP Computer Science A Unit 4 Section 2 (For Loops)

10th - 12th Grade

5 Qs

quiz-placeholder

Similar activities

For Loop Method

For Loop Method

10th - 12th Grade

10 Qs

Java Arrays Quiz Review

Java Arrays Quiz Review

9th - 10th Grade

10 Qs

Loops

Loops

10th Grade

10 Qs

Introduction to Loops

Introduction to Loops

10th Grade

10 Qs

Question Type: Pseudocode

Question Type: Pseudocode

10th - 12th Grade

8 Qs

AP Computer Science Unit 2

AP Computer Science Unit 2

9th - 12th Grade

9 Qs

APCSP Review

APCSP Review

9th - 12th Grade

9 Qs

Single Array

Single Array

11th Grade

10 Qs

AP Computer Science A Unit 4 Section 2 (For Loops)

AP Computer Science A Unit 4 Section 2 (For Loops)

Assessment

Quiz

Computers

10th - 12th Grade

Hard

Created by

Herman Galioulline

Used 138+ times

FREE Resource

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

Which of the following best explains how the difference in the two loop headers affects the output?

The output of the code segments is the same because the loops in each code segment terminate when i is 10.

The output of the code segments is the same because the loops in both code segments iterate 10 times.

The output of the code segments is different because code segment I iterates from i = 0 to i = 9 and code segment II iterates from i = 1 to i = 10.

The output of the code segments is different because code segment I iterates from i = 0 to i = 10 and code segment II iterates from i = 1 to i = 11.

Neither code segment produces output because both loop conditions are initially false.

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

Which of the following best explains how changing i < n to i <= n in line 2 will change the result?

An additional value will be printed because the for loop will iterate one additional time.

One fewer value will be printed because the for loop will iterate one fewer time.

There will be no change to the program output because the loop will iterate the same number of times.

An infinite loop will occur because the loop condition will never be false.

The body of the loop will not execute at all because the loop condition will initially be false.

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

How many $’s are printed as a result of executing the code segment?

0

5

6

7

50

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

How many times will the string "X" be printed as a result of executing the code segment?

1

7

8

35

More than 35 times, because the code segment will cause an infinite loop.

5.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Media Image

Which of the following for loops could be used to replace the for loop in the original code segment so that the original and the revised code segments store the same value in total?

Media Image
Media Image
Media Image
Media Image
Media Image