Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
medium Solved by 2 students

Nested Loop With Break Statement

Mark
< Prev
Next >

What is printed when the following program is executed?

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

5

B

6

C

3

D

9

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.

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|