In Java Serialization means an ability to persist the state of your object. In simple terms writing it into a byte stream. It is at the core of multiple other advanced technologies like Hibernate, RMI, JPA, EJB, JMS etc. Java serialization allows you to write the state of your object, a term which is commonly known as marshalling. To achieve serial...

Read More

Serialization is a general concept in Computer Science. Serialization is the process of converting objects into a format that can be stored in a file, memory or transmitted over the network and reconstructed in the same or similar environment. Serialization can be used to make a deep clone of an object. The process of Serialization is also known as...

Read More

We use the modifier transient.If an instance variable is marked transient then Java serialization process simply skips it. Lets modify our Vehicle class and run the same program. import java.io.Serializable; public class Vehicle implements Serializable { private transient Integer vehicleId; private String vehicleName; public Vehicle()...

Read More

This is a tricky interview question. Consider the following example. I have a class Person. public class Person { private final String name ; public Person(String name) { super (); this .name = name ; } } Now I have a child class Employee extending the Person class and implementing the Serializable interface. packag...

Read More

Since the super class implements Serializable then all the sub classes are Serializable by default. Consider the following Person class. public class Person implements Serializable{ private final String name ; public Person(String name) { super (); this .name = name ; } } Now as Person is implementing Serializable, ...

Read More

Directly quoting from Javadocs here, since it probably describes SerialVersionUID in best manner :The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that a...

Read More

From this post we already knew that if the super class implements Serializable then all its sub classes are Serializable by default. And we can not unimplemented an interface in Java so its not really possible to make it Non Serializable class. But there is a way to avoid serialization of the child class. To avoid serialization we need to implement...

Read More

When we serialize an object, the entire object graph is saved by making a deep copy of all the instance variables.This makes it somewhat of an alternative to cloning in Java.However, all the instance variables must also implement Serializable interface.Lets see what happens if an instance variable does not implement the Serializable interface. Cons...

Read More

Transient keyword is used in serialization process to prevent any variable from being serialized, so if you have any field which is not making sense to serialize, you can simply declare that as transient and it won't be serialized.Any variable whose value can be calculated from other variables doesn't require to be saved. For example if you have a ...

Read More

When you use Serializable interface, your class is serialized automatically by default. But you can override writeObject () and readObject () two methods to control more complex object serialization process. When you use Externalizable interface, you have a complete control over your class's serialization process. The java.io.Externalizable interfa...

Read More

Deserialization is the process by which the object previously serialized is reconstructed back into it’s original form i.e. object instance. The input to the deserialization process is the stream of bytes which we get over the other end of network OR we simply read it from file system/database or memory. One question arise immediately, what is writ...

Read More

FOLLOW US ON LinkedIn



Explore Tutu'rself