+ 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); } }

30th Dec 2017, 1:36 AM
Gustavo
Gustavo - avatar
6 Respostas
+ 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 : )
30th Dec 2017, 8:23 AM
Ipang
+ 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 : )
30th Dec 2017, 8:07 AM
Ipang
+ 3
I think @Gustavo making fun😀😀😀 but output is 12. no doubt.
30th Dec 2017, 7:17 PM
Ramshek Rana
Ramshek Rana - avatar
+ 2
b.) 12
30th Dec 2017, 2:39 AM
Bakel
Bakel - avatar
+ 2
12 ?? may be run the code and see output bro
30th Dec 2017, 9:47 AM
Prashanth Kumar
Prashanth Kumar - avatar
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
30th Dec 2017, 3:00 AM
Ipang