0
what is the output of the following code below ?
int a = 11; int b = 12; int c = 40; if (a > 100 || b > 3) { System.out.println(a); } else { System.out.println(c); } i dont understand about the code above...plz help me
3 Answers
+ 12
Hello !!
The variables a is initialized to 11 and b to 12.
In if condition, a>100 || b>3 evaluates to be true as a>100 is false as 11 is not greater than 100 but b>3 is true as 12 is greater than 3. And in between there is a logical OR operator. So any one of two condition would be true and here one condition is treu so the if block evalutes to be true. So the value of a i.e. 11 is printed.
Hope this helps !!!
+ 1
The condition is if a>100 OR b>3. b>3 so it prints a. Output is just 11.
+ 1
as first condition is false ....but second is true....so for or operator any 1 conditions satisfying results in condition being true....so the value of a is printed