QUESTION IMAGE
Question
consider the following: int a = 5; int b = 2; system.out.println(a + 2 * b--); system.out.println(b); which of the following statements is true?
Step1: Evaluate the first print statement
In Java, for System.out.println(a + 2 b--);, first, we calculate the expression a + 2 b--. Here, a = 5 and b = 2. The post - decrement operator b-- first uses the value of b in the expression and then decrements it. So, a+2 b = 5+22=5 + 4=9. After this operation, b becomes 1.
Step2: Evaluate the second print statement
The second System.out.println(b); will print the value of b which is 1 after the post - decrement operation in the previous step. So the output will be 91.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
91