This post is about the NotSerializableException in java.
So, serialization is the process where the state of the object is transformed into a stream of bits and vice-versa.
This exception NotSerializableException occurs when a POJO is doesn’t implements Serializable interface.
When you are trying to write a object into a file with the help of ObjectOutputStream.writeObject(). It checks for whether the object is serialized or not. If the object is not serialized then it throws the exception.
So, on serialization all the instance variables object state will be serialized except transient variablea and static.
In serialization we can find the serial version id by using
Open command prompt go to the complied location of the class file.
Type-> serialver classname.
As below you can get the serial version UID.
A: static final long serialVersionUID = 1847304848424810035L;