Question discussion

What is the output for the below code ?1. public class Test{2. public static void main(String[] args){3. int i = 010;4. int j = 07;5. Syste…

314228Medium 1 reply 691 views
0
What is the output for the below code ?1. public class Test{2. public static void main(String[] args){3. int i = 010;4. int j = 07;5. System.out.println(i);6. System.out.println(j);7. }8. }
  • A8 7
  • B10 7
  • CCompilation fails with an error at line 3
  • DCompilation fails with an error at line 5
  • ENone of these
Correct answer: A

Discussion 1

0
CCommunity
8 7

By placing a zero in front of the number is an integer in octal form. 010 is in octal form so its value is 8