+ 4

Can you solve this Java code? Surprise Answer

/*what comes in the blank underscore, if this is a valid code. Read the question carefully, if you dont know, dont downvote....*/ int x = 2_0_1__6; System.out.print(x+1); //2017 was the output produced //NO ARITHMETIC OPERATORS WERE USED //you will be surprised by the answer.

17th Jul 2017, 7:55 PM
Food
Food - avatar
12 Answers
+ 3
Java allows underscore within literals. int x = 123_45___8; will work. x will be 123458; So, the code itself is correct. Or Underscore should come in the place of underscores.
19th Jul 2017, 4:08 AM
Food
Food - avatar
+ 7
int x = 200+1816;
18th Jul 2017, 12:40 AM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 7
@food don't know java, but it simply prints x+1 which is 2016+1
19th Jul 2017, 3:59 AM
Lord Krishna
Lord Krishna - avatar
+ 5
@food don't let Einstein be criticised for me!!!!!! and by the way , your question says "blank underscore" so they are blank.....their are nothing in their places........so the statement simply is int x = 2016;
19th Jul 2017, 12:25 AM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 5
@food....๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘.......AWESOME........ but donโ€™t try to criticise Einstein for me!!!!!!!!
19th Jul 2017, 8:40 AM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 3
ok some hint needed!!!!
18th Jul 2017, 5:08 PM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 1
ha ha ha there is one einstein... honestly, that was not my intention. but there is another answer. so simple answer. find it,
18th Jul 2017, 6:13 AM
Food
Food - avatar
+ 1
@Chirag Ghosh I want you to find the answer Einstein. You made it that time. But operators not allowed. I should have mentioned that, that day. Cmon try it. for me
18th Jul 2017, 4:21 PM
Food
Food - avatar
+ 1
@Chirag Ghosh ok ok answer inside question itself. pls find it, I am waiting.. If you dont find it, then you leave me no choice than changing the question to "Even Einstein can't solve this"
18th Jul 2017, 5:55 PM
Food
Food - avatar
+ 1
@Chirag Ghosh run that piece of code as is. You will see the answer.
19th Jul 2017, 3:43 AM
Food
Food - avatar
+ 1
@Chirag Ghosh Hi, I never meant that (seriously). But seriously, I was just kidding.
19th Jul 2017, 12:47 PM
Food
Food - avatar
+ 1
2017 right answer
29th Sep 2019, 8:56 AM
Mohammad
Mohammad - avatar