What will be the output after compiling and running following code?
public class Test{
public static void main(String... args){
int x =5;
x *= 3 + 7;
System.out.println(x);
}
}
public class Test{
public static void main(String... args){
int x =5;
x *= 3 + 7;
System.out.println(x);
}
}
A. 22
B. 50
C. 10
D. Compilation fails with an error at line 4
E. None of these
Answer: Option B
Solution(By Examveda Team)
x *= 3 + 7; is same as x = x * (3 +7) = 5 * (10) = 50 because expression on the right side is always placed inside parentheses.
Related Questions on Operators
Join The Discussion