Menu
Question Index
...

What will be the output of the following program?

class ContinueExample
{
    public static void main(String s[])
    {
        int sum = 0;
        out : for (int i = 2; i <= 10; i++)
        {
            if (i % 3 == 0)
                break out;
            if (i == 8)
                break;
            sum += i;
        }
        System.out.println("sum = " + sum);
    }
}


sum = 18
sum = 36
sum = 2
Compilation Error
Runtime Error

Doubts

Problems

Topic: Using break In Nested Loop Java Program

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App