Question 54)
What will happen when you attempt to compile and run the following code?
public class Inc{
public static void main(
String argv[]){
Inc inc = new Inc();
int i =0;
inc.fermin(i);
i = i++;
System.out.println(i);
}
void fermin(int i){
i++;
}
}
1) Compile time error
2) Output of 2
3) Output of 1
4) Output of 0
The answer is 4, i.e., i=0. But I still cannot understand why
{int i=0; i=i++;} will be 0. Can somebody explain why? Thank you.