This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I would expect Hi to be printed twice. This is because x++ will only increment after the expression has been resolved. So the first time x =0, the second it will be 1. Using ++x means that x will be incremented first before the expression is resolved. So, x's first value would be 1. Hence Hi should be printed once. I haven't run this myself but this is the output I would expect.
Tricky question Sarim, or just a trick question maybe. The code doesn't compile, since there is no method. I've put your statements inside a main method and run the code. "Hi" is printed just once, which may surprise if you don't notice the semi-colon at the end of the while statement. If you take away the semi-colon then Andrew is right for x++ and ++x. I wonder if there will be anything like this in the exam.