+ 2

Its challenge to all sololeran users to give its output

import java.util.*; class challenge { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int x=012; System.out.println(x); } }

16th Dec 2017, 3:27 PM
Ritik
Ritik - avatar
4 Réponses
+ 15
012 => Octal (Base 8) => 1 * 8 + 2 = 10.
16th Dec 2017, 3:55 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 5
Here 012 is not treated as integer (like 12), in actual it takes input as octal number whose base is 8 , so it then converts into decimal whose value is 10 and we get the output = 10.
16th Dec 2017, 7:06 PM
Anish Kumar Arya
Anish Kumar Arya - avatar
+ 2
I dont know... lets see what will PROs answer 😮
16th Dec 2017, 3:34 PM
Sad
Sad - avatar
+ 2
I dont have that skills, that's why I did not get it.😮
16th Dec 2017, 3:56 PM
Sad
Sad - avatar