What are Transient Variables? What Role do they Play in Serialization Process

The transient keyword in Java is used to indicate that a field should not be serialized. Once the process of de-serialization is carried out, the transient variables do not undergo a change and retain their default value. Marking unwanted fields as transient can help you boost the serialization performance. Below is a simple example where … Read more

What are the Alternatives to Serialization? If Serialization is not used, is it Possible to Persist or Transfer an object using any other Approach

In case, Serialization is not used, Java objects can be serialized by many ways, some of the popular methods are listed below: Saving object state to database, this is most common technique used by most applications. You can use ORM tools (e.g. hibernate) to save the objects in a database and read them from the … Read more

Does Setting the serialVersionUID Class Field Improve Java Serialization Performance?

Declaring an explicit serialVersionUID field in your classes saves some CPU time only the first time the JVM process serializes a given Class. However the gain is not significant, In case when you have not declared the serialVersionUID its value is computed by JVM once and subsequently kept in a soft cache for future use. … Read more

What would happen if the SerialVersionUID of an object is not defined

If you don’t define serialVersionUID in your serilizable class, Java compiler will make one by creating a hash code using most of your class attributes and features. When an object gets serialized, this hash code is stamped on the object which is known as the SerialVersionUID of that object. This ID is required for the … Read more

What is a Serial Version UID (serialVersionUID) and why should I use it? How to generate one

The serialVersionUID represents your class version, and you should change it if the current version of your class is not backwards compatible with its earlier versions. This is extract from Java API Documentation The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that … Read more