ICSE Class 9 Computer Applications
Question 6 of 21
Operators in Java — Question 6
Back to all questions 6
Question Question 6
If a = 5, b = 9, calculate the value of:
a += a++ - ++b + a
a += a++ - ++b + a
⇒ a = a + (a++ - ++b + a)
⇒ a = 5 + (5 - 10 + 6)
⇒ a = 5 + 1
⇒ a = 6
a++ first uses the current value of a (which is 5) in the expression and then increments it to 6. ++b first increment the current value of b to 10 and uses this incremented value in the expression.