- public class Question { public static void main(String args[]) { int i=10; System.out.println("i="+++i); }
-
i=0
-
i=11
-
invalid argument to operation
-
none
The expression +++i is syntactically invalid in Java. The ++ increment operator requires a variable operand immediately after it, but here it's followed by +, causing a compilation error.
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
+++iis a post-increment operator applied to the variablei. It increments the value ofiby 1 and returns the original value ofi. - 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.