+ 2
What is the output of the following code?
I can not figure out the output of this question, can anyone help? ------------------------------------------------------------------------------ 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); }
4 ответов
+ 7
int a =11,b =12,c =40;
//● false OR true evaluates to true, so if() block will execute.
//● if any of conditions separated by OR returns true then whole condition evaluates to true
if (a>100 || b>3) {
System.out.println(a);
//● prints 11
} else {
System.out.println(c);
}
+ 5
|| = Or
&& = and
at last output is 11 .
//System.out.println(a);
+ 1
Try using code playground. Paste this code and run it and you will see result
0
La salida es 11
// este operador (||) ejecuta cualquier a de las dos condiciones, siempre y cuando una de las dos sean verdadero.
( a> 100 || b> 3) esto quiere decir que si (a) es mayor a (11) entonces imprimir (11) sino, imprimir (b) siempre y cuando (b) sea mayor a (3)
(a) no es mayor 100// y (b) si es mayor a 3 // pero hay una trampita..
no esta el// System.out.println(b); // pero si esta System.out.println(c);