Menu
Question Index
...

What will be the output of the following program?

public class TechMan {
    public static void main(String[] args) {
        int x = 1;
        int y = 6;
        while (y--) {
            x++;
        }
        System.out.println("x = " + x + " y = " + y);
    }
}


x = 6 y = 0
x = 7 y = 0
x = 6 y = -1
x = 7 y = -1
Compilation Error or Runtime Error

Doubts

Problems

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