int x = 1 + 2 * 3;
System.out.println(x);What does this print, and is the code correct?
- A
Prints 6; addition is performed first
- B
Compile error
- Ccheck_circle
Prints 7; multiplication has higher precedence than addition
- D
Prints 9; left-to-right evaluation
Explanation
Java follows standard math precedence: 2 * 3 = 6, then 1 + 6 = 7.