This question is from oracle website (sample questions).
output is 7 7 0
but according to the answers given in the website its 0 7 0.
can any one please tell me what is wrong with this code ? i know that static variables cannot be serialized.
you can check the question Here
Like you say, statics aren't serialized. However.... This code is launched during one instance of a JVM. You set the static variable to 7, and the reason it prints 7 after deserialization is because it is still 7. But it has nothing to do with the deserialization, it's just that the value hasn't changed since you serialized your object t.
Hope that was clear...
EDIT: As for the answer according to the website, I assume its an error.