Menu
Question Index
...

What will be the output of the following program?

class NestedFor
{
    public static void main(String s[])
    {
        for(int i = 2; i <= 5; i++ )
        {
            for(int j = 7; j <= 9; j++ )
            {
                System.out.println(" i = " + i + " j = " + j);
            }
        }
    }
}


i = 2 j = 7
i = 2 j = 8
i = 2 j = 9
i = 3 j = 7
i = 3 j = 8
i = 3 j = 9
i = 4 j = 7
i = 4 j = 8
i = 4 j = 9
i = 5 j = 7
i = 5 j = 8
i = 5 j = 9
No Output
Compilation Errors
i = 2 j = 7
i = 2 j = 8
i = 3 j = 7
i = 3 j = 8
i = 4 j = 7
i = 4 j = 8
i = 5 j = 7
i = 5 j = 8

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