Which interface must a class implement to be serializable in Java?

The story behind the answer

A Java class must implement the Serializable interface to use Java's built-in object serialization mechanism. Serializable is defined in the java.io package and acts as a marker interface, meaning it declares no serialization methods of its own.

Implementing Serializable tells ObjectOutputStream that instances of the class are eligible to be converted into a byte stream. During default serialization, Java records the class information and its non-static, non-transient fields. When an object is restored, ObjectInputStream reconstructs it from that stream.

Serialization also follows referenced objects. If a serializable object contains a non-transient field referring to an object that is not serializable, writing the object can fail with NotSerializableException. Developers can exclude fields with the transient keyword or customize the process with special methods such as writeObject and readObject.

The other options are unrelated marker or behavior interfaces: Runnable describes executable tasks, Comparable defines natural ordering, and Cloneable signals support for Object.clone. A frequent misconception is that Serializable itself contains methods to implement; it does not. Its purpose is to opt a class into the mechanism and its compatibility obligations.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: