Write a program that demonstrates the Boolean type values.

Category : Java | Sub Category : Data type, Variable and Arays | By Prasad Bonam Last updated: 2020-09-28 09:29:25 Viewed : 542


(Data type, Variable and Arays)

Write a program that demonstrates the Boolean type values.


Source Code: BoolTest.java

 /**

 *

 * .Write a program that demonstrates the Boolean type values.

 */

class BoolTest { // This line daclare a new class & the class defination is start.

     public static void main(String a[]) { // This line begins the main() method.

         boolean b; // daclere a boolean variable.

         b = false; // Initialize b is false.

         System.out.println("b is " + b); // display b .

         b = true; // now b initialize is true.

         System.out.println("b is " + b); // display it.

         if (b)

              System.out.println("this is executed. ");

         // if condition is true then this string is print

         b = false; // b again false.

         if (b) // initialize if condition

              System.out.println("this is not executed. ");

         // this line is not display because b is false.

         System.out.println("10 > 9 is " + (10 > 9)); // out come relational operator Boolean which is true

     } // end of main function

} // end of a class

 OUTPUT:




Search
Related Articles

Leave a Comment: