Is there an absolute guarantee that the jvm will not need so much ram during the execution of whatever complicated stuff happens at line 10, it decides to unload MyClass, and consequently, when line 11 is reached, MyClass.x is back to zero?
The only way for a class to get unloaded (i.e., GCed) is if its classloader gets unloaded. In this particular case -where the only classloaders involved are the ones the JVM creates for running the app- there is no possibility of the class getting unloaded before the JVM exits.
In general, you never need to worry about classes getting unloaded unless you're using code whose very point is to do just that - like OSGi environments. For the purposes of the exam, there's nothing to worry about.