Clean • Professional
Java provides two interfaces for object serialization:

Both help convert objects into a byte stream, but they work very differently.
Serializable is a marker interface (no methods) that enables default serialization.
Example (Automatic):
public class Student implements Serializable {
int id;
String name;
}
When a class implements Serializable, the JVM automatically:
ObjectOutputStream / ObjectInputStreamtransient keywordserialVersionUID for versioningExternalizable is a subinterface of Serializable but gives full manual control over serialization.
Used when you want to customize how objects are saved and restored.
It has two methods:

public void writeExternal(ObjectOutput out) throws IOException;
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException;
Example (Custom):
class Employee implements Externalizable {
int id;
String name;
public void writeExternal(ObjectOutput out) throws IOException {
out.writeInt(id);
out.writeUTF(name);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
id = in.readInt();
name = in.readUTF();
}
}
transient| Feature | Serializable | Externalizable |
|---|---|---|
| Type | Marker Interface | Interface with methods |
| Control | JVM controls serialization | Developer controls serialization |
| Methods | None | Must implement writeExternal() & readExternal() |
| Default Behavior | Yes | No (everything is manual) |
| Performance | Slower (stores full object) | Faster (store only needed fields) |
| transient Support | Yes | Not needed (manual control) |
| No-arg Constructor | Not required | Required |