Menu
Question Index
...

What will be the output of the following program?

class ForSample
{

    public static void main(String s[])
    {
        int i = 0;
        for(;i <= 5; i++ )
        {
            System.out.println("i = " + i );
        }

        System.out.println("i after the loop = " + i );
    }
}


i = 0
i = 1
i = 2
i = 3
i = 4
i = 5
i after the loop = 6
i = 0
i = 1
i = 2
i = 3
i = 4
i = 5
i = 6
Compilation Errors
i = 0
i = 1
i = 2
i = 3
i = 4
i = 5

Doubts

Problems

Topic: 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