Menu
Question Index
...

What will be the output of the following program?

class NestedForloop
{
    public static void main(String s[])
    {
        int sum = 5;        
        int i = 1;
            
        for( ; i < 4; )
        {
            for(int j = 1; j < 4; )
            {
                for(int k = 1; k < 4; k++)
                {
                    sum = (i * j);
    
                    i++;
                    j++;
                    k++;
                }
            }
        }
        System.out.println("Sum = " + sum);
    }
}


Sum = 35
Sum = 576
Sum = 16
Compilation Error
Runtime Error

Doubts

Problems

Topic: Nested for Loop In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App