1(vii)
What is the output of the code snippet given below?
int lives = 5; System.out.print(lives--); System.out.print(lives);
- (a)4 3
- (b)5 4
- (c)5 3
- (d)4 4
Show SolutionHide Solution↓
5 4
Reason — In System.out.print(lives--), the post-decrement operator (lives--) prints the current value of lives (which is 5) first, then decreases it to 4. The next System.out.print(lives) prints the updated value 4.