August 13, 2025
๐ Java Interview Questions โ Episode 12
๐ก What is the Serializable interface in Java?
๐ฆ And why do we use it?
The Serializable interface is a marker interface โ it doesnโt have any methods, but it signals the JVM that a class can be serialized.
๐ Serialization = converting an object into a stream of bytes, so it can be:
โ Saved to a file
โ Sent over a network
โ Stored in a cache
โ Transferred between JVMs
๐งฉ To make a class serializable, just implement:
class User implements Serializable { ... }
โ ๏ธ Don't forget:
Transient fields are not serialized.
All nested objects must also be serializable.