E
Elite Edition

What is the use of Serializable interface in Java?

Author

David Edwards

Published Mar 02, 2026

What is the use of Serializable interface in Java?

1. To save/persist state of an object. 2. To travel an object across a network. Only the objects of those classes can be serialized which are implementing java.io.Serializable interface. Serializable is a marker interface (has no data member and method). It is used to “mark” java classes so that objects of these classes may get certain capability.

What is serialization in Django?

In Django REST Framework the very concept of Serializing is to convert DB data to a datatype that can be used by javascript. Serializers allow complex data such as querysets and model instances to be converted to native Python datatypes that can then be easily rendered into JSON, XML or other content types.

What is the difference between serialization and deserialization?

Last Updated : 10 Oct, 2019 Serialization is a mechanism of converting the state of an object into a byte stream. Deserialization is the reverse process where the byte stream is used to recreate the actual Java object in memory. This mechanism is used to persist the object.

What is the use of serializer in rest?

Serializers also provide deserialization, allowing parsed data to be converted back into complex types, after first validating the incoming data. The serializers in REST framework work very similarly to Django’s Form and ModelForm classes.

How to serialize interface property of an XML Object?

You can use ExtendedXmlSerializer. This serializer support serialization of interface property without any tricks. ExtendedXmlSerializer support .net 4.5 and .net Core. Replacing the IModelObject interface with an abstract or concrete type and use inheritance with XMLInclude is possible, but seems like an ugly workaround.

Serialization is done using ObjectOutputStream. Deserialization is the reverse process where the byte stream is used to recreate the actual Java object in memory. This mechanism is used to persist the object.

Why do I get an invalidclassexception when serializing an object?

If the reciever has loaded a class for the object that has different UID than that of corresponding sender’s class, the Deserialization will result in an InvalidClassException. A Serializable class can declare its own UID explicitly by declaring a field name. It must be static, final and of type long.