Menu
Question Index
...

What will be the output of the following program?

class BoolLogic
{
    public static void main(String s[])
    {
        boolean a = true;
        boolean b = false;

        System.out.println(" a | b = " + (a | b));
        System.out.println(" a & b = " + (a & b));
        System.out.println(" a ^ b = " + (a ^ b));
        System.out.println(" a ^ !b = " + (a ^ !b));
        System.out.println(" !a && b = " + (!a && b));
        System.out.println(" !a || !b = " + (!a || !b));
    }
}


a | b = true
a & b = true
a ^ b = true
a ^ !b = false
!a && b = false
!a || !b = false
a | b = true
a & b = true
a ^ b = true
a ^ !b = false
!a && b = true
!a || !b = true
a | b = true
a & b = false
a ^ b = false
a ^ !b = true
!a && b = false
!a || !b = true
a | b = true
a & b = false
a ^ b = true
a ^ !b = false
!a && b = false
!a || !b = true

Doubts

Problems

Topic: Short Circuit Logical Operators 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