int x=3;
int y = x++ + ++x;
1) evaluate x++, and push the value onto the stack
vars: {y, 3} stack: {3}
2) increment x
vars: {y, 4} stack: {3}
3) evaluate ++x and push the value onto the stack
vars: {y,4} stack: {4}
4) increment x
vars: {y, 5} stack: {4}
5) add the value of x from the stack to the value of x from the stack, and store the result in y
vars: {8, 5} stack: {}
So y is 8 and x is 5
I would definitely not recommend writing this sort of code as it's confusing for people to understand. For the java exam you need to be able to interpret code statements like this in case
you should come across them in other peoples code.
(By the way Ros Bain != ashok reddy devaram
However I notice he has a very very similar taste in questions to me - very curious!)
The information about the use of the stack was very helpful.
Thanks for all your help on this.