+ 1

what is

What is the output of the following code? int a = 11; int b = 12; int c = 40; if (a > 100 || b > 3) { System.out.println(a); } else { System.out.println(c); }

21st Jan 2018, 10:04 PM
Ali Bellali
Ali Bellali - avatar
3 Answers
+ 21
or(||) returns true if any condition evaluates to true //so output will be 11 but if there will be and(&&) in place of || then 2nd condition will not get checked bcz 1st condition itself results false & output will be 40
22nd Jan 2018, 2:11 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 13
SoloLearn has compilers, so you just need to copy paste it then run it... instead of polluting the Q&A section :)
21st Jan 2018, 10:08 PM
Dapper Mink
Dapper Mink - avatar
+ 12
is a greater than 100? no is b greater than 3 yes! since you use the OR operator only one statement has to be true so the output will be 11
21st Jan 2018, 10:56 PM
Kamil
Kamil - avatar