Multiple choice technology programming languages

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. }

  1. 8 7

  2. 10 7

  3. Compilation fails with an error at line 3

  4. Compilation fails with an error at line 5

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In Java, integer literals starting with 0 are interpreted as octal (base-8) numbers. Octal 010 equals decimal 8 (1×8 + 0), and octal 07 equals decimal 7. The code compiles and prints '8' then '7' - no error, just a different number system than expected.