Q: Why does 012 % 10 = 0 in Java? I am trying following program.
int var = 012;
int result = var % 10;

output: 
result = 0

I am not able to understand why java is not able to consider 012 as 12.

A: In Java, integer literals that start with 0 are interpreted as octal numbers.
So, 012 is the number 1 x 8 + 2 = 10 (in decimal), not 12 (decimal).
012 % 10 == 10 % 10 == 0
