javachick1
2008-07-13 13:46:37 UTC
The question asks: Assume that we declare int x=1,y=2; each time before Java executes each of the following statements; fill in the states for these variables after each statement executes (or write NLES for not legal expression statement).
My answers are below (the comments) .....
A) y == x; // not a legal statement
B) x = y += 2; // x is now 4 and y is 2 (doesn't change)
C) y = (2*x)++; // y is now 3, and x is still 1
D)x = x++; // x is now 2, and y does not change
E) y = 1 + (x = ++ y); // illegal expression