Question: I'm stumbled upon understanding java serialization. I have read in many documents and books that static and transient variables cannot be serialized in Java.
 We declare a serialVersionUid as follows.

```
private static final long serialVersionUID = 1L;

```

If a static variable was not serialized then, we often face an exception during the de-serialization process. 

```
java.io.InvalidClassException

```

in which the serialVersionUID from the deserialized object is extracted and compared with the serialVersionUID of the loaded class.

To my knowledge i think that if static variables cannot be serialized. There is no point of that exception. I may be wrong because I'm still learning.

Is it a myth that "Static and transient variables in java cannot be serialized". Please correct me, I'm in a mess about this concept.

Answer: 
The `serialVersionUID` is also serialized in this case.

*Any static variable that is provided a value during class initialization is serialized*.

However in normal cases, where you would provide the value to a static variable at the main class / run-time would not be serialized.

You can try to access the `serialVersionUID` by making it public and try to access it after deserialization.

You can refer "<http://javabeginnerstutorial.com/core-java-tutorial/transient-vs-static-variable-java/>" for more information.

Hope that helps. Cheers !!
No, if a class have static variable then at the time of serialization that variable will be skipped . because static variable is unique for all object and serialization is used for only save the object properties ( state of object ).
static variable is a property of class