Menu
Question Index
...

What will be the output of the following program?

class DemoOnCompare {
    public static void main(String args[]) {
        int first = 10, second;
        if (first < 10)
            second = 1;
        if (first >= 10)
            second = 2;
        System.out.println("y is " + second);
    }
}


y is 0
y is 2
y is 10
y is 111
Compilation Error or Runtime Error

Doubts

Problems

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