Question

link

Predict the output of following program.

public static void main(String[] args) {
    int a = 012;
    System.out.println("a is " + a);
}

Analysis

Putting a 0 before an integer constant makes it an octal number and putting 0x (or 0X) makes it a hexadecimal number.

Answer: 10.