java Logical operator In java and programm

 

Logical operator In java

 

Q.1] Type of logical operator and its syntax?

1.       Logical  AND  Syntex[ && ]

2.       Logical  OR  Syntex[ || ]

3.       Logical  NOT  Syntex[ ! ]

Q.2 ] write A program to logical all operator in side ?

class LogicalProgram {

   public static void main(String  args[]) {

       int x=5, y=10;

      boolean z;

    z=((x>y) && (x<y) &&(x==y);

   System.out.println(“the value of Z=” +z);

  z=((x>y) || (x<y) ||(x==y);

   System.out.println(“the value of Z=” +z);

 z=((x>y) ! (x<y) ! (x==y);

   System.out.println(“the value of Z=” +z);

}

}

v  Boolean:- is a data type that has two values that is it may be true or false .it is not storing any value but stores state.

Q.3] write a program to use OR operator?

Program example:-      class   OrOperator   {

                                                   public static void main(String  args[])    {

                                                      int   x=32;

                                                    if  (x>20  && x<50)   {

                                    System.out.println(“the value is with in range”);

                                           }

                                            if  (x <20)   {

                                                            System.out.println(“the value is less than 20” );

                                                            }

                                                  else   {

                                                            System.out.println(“the value is getter than 50” );

                                                            }

                                                   }

                             }



Post a Comment

0 Comments