To answer this question, let's analyze the given code:
public class Question {
public static void main(String args[]) {
int i=10;
System.out.println("i="+++i);
}
}
In this code, the expression "i="+++i
is being printed using the System.out.println()
method. Let's break down this expression:
- The
+++i
is a post-increment operator applied to the variable i
. It increments the value of i
by 1 and returns the original value of i
.
- The
"i="
is a string literal that is concatenated with the result of the post-increment operation.
So, the expression "i="+++i
is equivalent to "i=" + (++i)
.
However, the code provided uses +++i
instead of ++i
. This is not valid syntax in Java. The ++
operator should be used either before or after the variable, not both. Therefore, the code will result in a compilation error, indicating an invalid argument to the operation.
Therefore, the correct answer is C) invalid argument to operation.