Java program to perform the boolean operations
KW.java
class KW
{
    public static void main(String args[])
    {
        boolean a=true,b=false;
        System.out.println("———————————————————————————————————————————");
        System.out.println("Program to perform the boolean operations");
        System.out.println("———————————————————————————————————————————");
        System.out.println(a+" |  "+b+"\t| "+(a|b));
        System.out.println(a+" &  "+b+"\t| "+(a&b));
        System.out.println(a+" ^  "+b+"\t| "+(a^b));
        System.out.println(a+" || "+b+"\t| "+(a||b));
        System.out.println(a+" && "+b+"\t| "+(a&&b));
        System.out.println(a+" == "+b+"\t| "+(a==b));
        System.out.println(a+" != "+b+"\t| "+(a!=b));
        System.out.println("!("+a+" || "+b+")| "+!(a||b));
        System.out.println("———————————————————————————————————————————");
    }
}
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW ——————————————————————————————————————————— Program to perform the boolean operations ——————————————————————————————————————————— true | false | true true & false | false true ^ false | true true || false | true true && false | false true == false | false true != false | true !(true || false)| false ——————————————————————————————————————————— kodingwindow@kw:~$
Advertisement