+ 1

What will be the output and why?

public static void main(String args[]) { int x=033; System.out.println(x); }

7th Jun 2020, 2:08 PM
Jadhav Swati
Jadhav Swati - avatar
1 Answer
+ 3
You can test-run the code in Playground for getting the output. As for why; if an integral value be prefixed by a zero, it is assumed an octal value (base 8) instead of a decimal (base 10). https://en.m.wikipedia.org/wiki/Numeral_system 33 in octal equals to 27 in decimal.
7th Jun 2020, 2:21 PM
Ipang