Hello,
I am studying for
SCJP 6 Exam, and came across this question which shows code as asks for the output
The answer says 9 10 10 d 13 will be output. However, when I hand-traced the program, I keep getting 9 10 d 13. Can you please help? Below is my trace:
step 1: x is set to 7
step 2: x is incremented to 8 (because of static x++)
step 3:
string s is initialized to ""
step 4: for loop begins, y is set to 0
step 5: x is incremented to 9
step 6: case 9 appends 9 to string s
step 7: for loop, y is set to 1
step 8: x is incremented to 10
step 9: case 10 appends 10 to string s and breaks out of switch, y is set to 2
step 10: x is incremented to 11
step 11: case default appends d to string s
step 12: case 13 appends 13 to string s, y is set to 3
step 13: loop exits, and prints 9 10 d 13