Menu
Question Index
...

What will be the output of the following program?

public class ForTest
{

    public static void main(String[] args)
    {
        int m = 7;
        int n = m + 'a' - 'X';
        int i = m;
        for (; i <= n;) {
            m += i++;
        }

        System.out.println("i = " + i + " m = " + n + " n = " + m);
    }
}


i = 17 m = 16 n = 16
i = 17 m = 122 n = 16
i = 17 m = 16 n = 122
Compilation Error
Goes into infinite loop

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