+ 3
What is the output of this code? a) error. b) 12. c) null
public static void main(String[] args) { int x = 12; if (x > 12); { System.out.print(x); } }
9 odpowiedzi
+ 5
@Gordie I can imagine how I'd feel like to find this on a challenge, but I doubt you should fall into it anyway. Thanks for the details mate, there's always something new to learn : )
+ 3
@Gordie, interesting tricks, being written this way it makes sense, the code as in the OP question didn't, I suppose its a challenge question, I guess it has to be tricky that way, so not to be too easy : )
+ 3
I think @Gustavo making fun😀😀😀
but output is 12. no doubt.
+ 2
b.) 12
+ 2
12
??
may be
run the code and see output bro
0
Error, the if statement had a semicolon before opening curly brace. Change it to
if(x > 12) {
But even then it still outputs nothing because x equals 12, not more than 12.
Hth, cmiiw