Page 67 - CA_Blue( J )_Class10
P. 67

For example, if we take an expression (a>b II b>c), then the output will be:

                                  Condition 1               Condition 2            Condition 1 II Condition 2
                                     (a>b)                     (b>c)                      (a>b II b>c)
                                    0 / false                 0 / false                    0 / false
                                    0 / false                 1 / true                     1 / true

                                    1 / true                  0 / false                    1 / true
                                    1 / true                  1 / true                     1 / true

                 The ! Operator
                 The ! operator is known as the "Logical NOT" operator. It is a unary operator because it works only on one operand.
                 The outcome of this operator is false if the provided condition is  satisfied, and if the condition is not satisfied,  then
                 the outcome of the operator is true. For example, if we take an expression !(a>b), then the output will be:

                                         Condition (a>b)                          Result of ! ( a>b)
                                            0 / false                                 1 / true
                                             1 / true                                 0 / false

                  Program 4: To use logical operators.


























                 You will get the following output:




























                                                                                                                       65
                                                                                                      Operators in Java   65
   62   63   64   65   66   67   68   69   70   71   72