What is the result stored in x, after evaluating the following expression?
Given: int x = 5;
Expression: x++ * 2 + 3 * --x;
Views 26
Answer:
Answer: The expression evaluates as follows:
x++
returns 5 and then incrementsx
to 6.--x
decrementsx
back to 5 and returns 5.- Therefore, the expression becomes:
5 * 2 + 3 * 5 = 10 + 15 = 25
.
Hence, the result stored in x
is 25
.
Related Articles:
This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.
Join Our telegram group to ask Questions
Click below button to join our groups.