Knowee
Questions
Features
Study Tools

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] + " "); }}120 200 16120 200 14120 200 016016 is a compile error. It should be written as 16.

Question

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] + " "); }}120 200 16120 200 14120 200 016016 is a compile error. It should be written as 16.

🧐 Not the exact question you are looking for?Go ask a question

Solution 1

The output of the given code will be "120 200 14". This is because 016 is an octal number (base 8) in Java, and its decimal equivalent is 14. So, the program prints the decimal equivalents of the numbers in the array.

Solution 2

The output of the given code will be "120 200 14". This is because 016 is an octal number (base 8) in Java, and its decimal equivalent is 14. So, the program prints the decimal equivalents of the numbers in the array.

Solution 3

The output of the code will be "120 200 14". This is because 016 is an octal number (base 8) in Java, and its decimal equivalent is 14. So, the program prints the decimal equivalents of the numbers in the array.

Similar Questions

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

Determine output:public class Test{ public static void main(String[] args){ int[] x = {1, 2, 3, 4}; int[] y = x; x = new int[2]; for(int i = 0; i < x.length; i++) System.out.print(y[i] + " "); }}123400001200

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

What is the output of the following code :class MyClass {public static void main(String[] args) {int i=1,j=1;for (;i<3;i++){for(;j<4;j++);j++;System.out.print(i + j+" ");}}

What is the result of compiling and running the following code?public class Test{ public static void main(String[] args){ int[] a = new int[0]; System.out.print(a.length); }}

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.