You are here: Home / Topics / Program to explain Logical Or ( | ) and Logical Short-circuit Or ( || ) Operator.

Program to explain Logical Or ( | ) and Logical Short-circuit Or ( || ) Operator.

Filed under: Java on 2023-08-11 19:31:02

//  Program to explain Logical Or ( | ) and Logical Short-circuit Or ( || ) Operator.

class  ShortCircuitOr
{
public static void main(String args[ ]) 
{
 int a = 10, b = 20;
 
 if( (a > 5) || (++b < 10) )
 {
  System.out.println(" True ");
 }
 System.out.println(" b = " + b);
 
 if( (a > 5) | (++b < 10) )
 {
  System.out.println(" True ");
 }
 System.out.println(" b = " + b);
 
}
}


Output:

b = 20
True
b = 21

About Author:
V
Vinay Kumar     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.