| preferred AP College board partner for AP classes
AP Computer Science A/Unit 4: Iteration
Start Practice TestPractice Test
About Exam
easy Solved by 2 students
Equivalent For Loop Logic
< Prev
Next >

Which of the following code segments produces the same output as the given code segment?

for (int k = 1; k <= 100; k++)
    if ((k % 4) == 0)
        System.out.println(k);
A

for (int k = 4; k <= 100; k = k + 4)
System.out.println(k);

B

for (int k = 4; k <= 25; k = 4 * k)
System.out.println(k);

C

for (int k = 1; k <= 100; k++)
System.out.println(k % 4);

D

for (int k = 1; k <= 100; k = k + 4)
System.out.println(k);

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy