Question discussion

What is output of the following code:public class Test{ public static void main(String[] args){ int[] x = {120, 200, 016 }; for(int i = 0;…

321873Medium 1 reply 4,413 views
16
What is output of the following code:public class Test{ public static void main(String[] args){ int[] x = {120, 200, 016 }; for(int i = 0; i < x.length; i++) System.out.print(x[i] + " "); }}
  • A120 200 16
  • B120 200 14
  • C120 200 016
  • D016 is a compile error. It should be written as 16.
Correct answer: B

Discussion 1

0
CCommunity
120 200 14

016 is an octal number. The prefix 0 indicates that a number is in octal.