What will be the output of the following code?import java.util.*;public class Main{ public static void main(String args[]) { int i=01289; System.out.println(i); }}radio_button_uncheckedTrueradio_button_uncheckedFalseradio_button_unchecked1289radio_button_uncheckedCompilation Error
Question
What will be the output of the following code?import java.util.*;public class Main{ public static void main(String args[]) { int i=01289; System.out.println(i); }}radio_button_uncheckedTrueradio_button_uncheckedFalseradio_button_unchecked1289radio_button_uncheckedCompilation Error
Solution
The output of the code will be a Compilation Error.
In Java, any number starting with a '0' is considered as an octal number (base 8). But the octal number system only includes digits from 0 to 7. Here, the number '01289' includes '8' and '9', which are not valid digits in the octal number system. Hence, the Java compiler will throw an error.
Similar Questions
What will be the output of the following Java program?class mainclass { public static void main(String args[]) { boolean ct1 = true; boolean ct2 = false; if (ct1) System.out.println(ct1); else System.out.println(ct2); } }Options10truefalse
What will be the output of the following code?boolean flag = true;if (flag == false) { System.out.println("False");} else { System.out.println("True");}FalseTrueCompilation errorNo output
Select the correct answerWhat is the output of the following program?public class Test{ public static void main(String []args){ int i = 0; for(i = 0; i < 10; i++){ continue; } System.out.println(i); }}OptionsCompilation error0109
What will be the output of the following Java program? class scopevariable { public static void main(String args[]) { int c; c = 15; { int d = 36; System.out.print(c + " " + d); } System.out.println(c + " " + d); } }Options5 6 55 6 5 6Runtime errorCompilation error
What is the output of the following code?public class Solution { static int x = 10; public static void main(String args[]) { System.out.println(x); } }Options: Pick one correct answer from below100Compilation errorRuntime error
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.