JAVA Programming :: Basic Concepts - Discussion
Home > JAVA Programming > Basic Concepts > MCQs Questions Discussion
41 / 64
What is the output for the below code?
public class Test {
public static void main(String[] args){ int i = 010;
int j = 07;
System.out.println(i);
System.out.println(j);
}
}
public class Test {
public static void main(String[] args){ int i = 010;
int j = 07;
System.out.println(i);
System.out.println(j);
}
}
A8 7
B10 7
CCompilation fails with an error at line 3
DCompilation fails with an error at line 5
Answer: Option (Login/Signup)
Show Explanation
Asked In ::
STEP-BY-STEP
If we place a 0 before a number, then automatically it is treated as an octal value by the compiler.
Here, i is initialized as 010, which is the octal equivalent of 8.
And, j is initialized as 07, which is the octal equivalent of 7.
Hence, the output is-
8
7
Read Full Answer
Report Error
Please Login First Click Here