What will be printed when the following Java program is executed? public class Test { public static void main(String[] args) { int i = 010; int j = 07; System.out.println(i); System.out.println(j); } }
Explanation
In Java, integer literals starting with 0 are interpreted as octal (base 8) numbers. Therefore, 010 in octal is equal to 8 in decimal, and 07 in octal is equal to 7 in decimal. Hence, the program prints 8 first and then 7.