Java program to perform the boolean operations
Codeaft.java
class Codeaft { 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
codeaft@codeaft:~$ javac Codeaft.java
codeaft@codeaft:~$ java Codeaft ——————————————————————————————————————————— 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 ——————————————————————————————————————————— codeaft@codeaft:~$
Comments and Reactions