private static int x=getValue();
During this assignment, the value of static instance variable Y is 0 and is not initialized to 5. In the next line only you are initializing Y to 5. That's why the output is 0.
If the output should have been 5, then you have to initialize the Y value before you actually use that value. Refer the below code to get the Output of 5 :