What will be the output of the following code?

class Main {
    public static void main(String[] args) {
        Boolean b1 = true;
        boolean b2 = false;
        boolean b3 = true;
        if ((b1 & b2) | (b2 & b3) & b3)
            System.out.print("alpha ");
        if((b1 = false) | (b1 & b3) | (b1 | b2))
            System.out.print("beta ");
Java allows the usage of bitwise operations in conditional expressions. The "b1 = false" expression in "if(b1 = false)" evaluates to "false", i. e. the value assigned to b1.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Sign Up Now
or Subscribe for future quizzes