Menu
Question Index
...

What will be the output of the following program?

class OutPut
{
    public static void main(String s[])
    {
        int i = 5;
        for(; i < 6 || i >= 0; )
            
            switch(i)
            {
                case 0:
                System.out.println("i is zero.");
                i++;
                break;
        
                case 1:
                System.out.println("i is one.");
                i++;
                break;
    
                case 2:
                System.out.println("i is two.");
                i++;
                continue;
    
                case 3:
                System.out.println("i is three.");
                i++;
                break;
        
                default:
                System.out.println("i is greater than three.");
                i -= 6;
            }
    }
}


i is zero.
i is one.
i is two.
i is three.
i is greater than three.
i is greater than three.
i is two.
i is three.
i is greater than three.
Compilation Error
Runtime Error

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