Choosing how to earn college credit? CLEP vs AP guide
| preferred AP College board partner for AP classes
hard Solved by 3 students

Nested Loop Tally

Mark
< Prev
Next >

A program calculates the total number of times an inner statement executes within nested loops.

What is printed when the following Java program is compiled and run?

public class QuestionTrace {

    public static void main(String[] args) {
        int count = 0;
        for (int i = 0; i < 3; i++) {
            for (int j = i; j < 3; j++) {
                count++;
            }
        }
        System.out.println(count);
    }
}
A

7

B

9

C

5

D

6

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: apfive@apfive.org|Instagram: @_apfive_|Privacy Policy|