Menu
Question Index
...

What will be the output of the following program?

public class AccessVariables {
    private static final boolean BOOLEAN = true;
    private static final boolean BOOLEAN2 = BOOLEAN;
    static boolean b1, b2;
    public static void main(String... args) {
        int b = 0;
        if (!b1)
            if (!b2) {
                b1 = true; b++;
                if (5 > 6) b++;
                if (!b1) b = b + 10;
                else {
                    if (b2 = BOOLEAN2) b = b + 100;
                    else if (b1 | b2) b = b + 1000;
                }
            }
        System.out.println("Number = " + b);
    }
}


Number = 0
Number = 4
Number = 101
Number = 111
Compilation Error or Runtime Error

Doubts

Problems

Topic: Other Advanced Topics 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