Page 341 - Computer_Science_F5
P. 341

Computer Science           Program Example 5.7:

            Java program to demonstrate relational operators


              public class RelationalOperators
          FOR ONLINE READING ONLY
              {
               public static void main(String[ ] args)
               {
                           int a = 300, b = 200;
                     boolean condition = true;
                     //These codes shows various conditional operators
                     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));
                     System.out.println(“condition==true :” + (condition == true));
                     }
                        }


             Output:


























                                      Figure 5.9: Relational operators

           (c) Bitwise operators
           This include Bitwise AND: &, Bitwise exclusive OR: ^, Bitwise inclusive OR: |
           and Shift operators: <<, >>, >>>. Table 5.9 shows the relational operators that are
           supported by Java language.

                                                 332
                                                                for Advanced Secondary Schools



     Computer Science Form 5.indd   332                                                     23/07/2024   12:34
   336   337   338   339   340   341   342   343   344   345   346