Menu
Question Index
...

What will be the output of the following program?

public class LoopExample
{
    public static void main(String[] args)
    {
        for (char i = 0, j = 6; i < 5 && j > 0; i++, --j)
        {
            System.out.print((int) i + " " + (int) j + ", ");
        }
    }
}


0 5, 1 4, 2 3, 3 2, 4 1,
0 6, 1 5, 2 4, 3 3, 4 2,
Some other output
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