Write a programme that demonstrate the Boolean logical operator

Category : Java | Sub Category : Operator | By Runner Dev Last updated: 2020-09-28 19:01:15 Viewed : 195


(Operator)

Write a programme that demonstrate the Boolean logical operator

Source Code: BoolLogic.java

/**

 * Write a programme that demonstrate the Boolean logical operator *

 */

public class BoolLogic { // calss name

     public static void main(String args[]) { // main method of programme

           boolean a = true; // Declare a

           boolean b = false; // Declare b

           boolean c = a | b; // Declare c

           boolean d = a & b; // Declare d

           boolean e = a ^ b; // Declare e

           boolean f = (!a & b) | (a & !b); // Declare f

           boolean g = !a; // Declare g

           System.out.println(" a = " + a); // Print value of a

           System.out.println(" b = " + b); // Print value of b

           System.out.println(" a|b = " + c); // Print value of c

           System.out.println(" a&b = " + d); // Print value of d

           System.out.println(" a^b = " + e); // Print value of e

           System.out.println(" (!a & b) | (a & !b) = " + f); // Print value of f

           System.out.println(" !a = " + g); // Print value of g

     } // main body of programme ended

} // class ended



Output:

 a = true

 b = false

 a|b = true

 a&b = false

 a^b = true

 (!a & b) | (a & !b) = true

 !a = false



Search
Related Articles

Leave a Comment:
evorrot
at 2022-04-02 19:36:37
effects of cialis on females [url=https://oscialipop.com]cialis online cheap[/url] Lvxykx Fluoxetine Next Day Delivery <a href=https://oscialipop.com>buying cialis online safe</a> Epigenetics in pain and analgesia an imminent research eld. https://oscialipop.com - cialis 40 mg When Will Cialis Come Off Patent