<Back
OCPJP test sometimes removes Serializable interface from the exam objectives, however you need to understand it for the sake of using ObjectInputStream and ObjectOutputStream.
In order to be serializable, an object's class need to implement, you know what -- Serializable -- interface. Serializable interface has no abstract object to override, so any class can implement Serializable interface for free. If you don't, NotSerializableException will be thrown at runtime when you call ObjectOutputStream's writeObject(Object) method. Besides, almost all the instance fields have to be either primitive or belong to class that implements Serializable interface. "Almost" because, if you mark a field as transient or static, it will be ignored during serialization and deserialization.
During Deserialization, neither constructors nor the (instance and static) initializers are called. As a result, the object get from deserialization process maintains the same values before they are serialized. Unless they are marked as transient or static. Transient variable get default value and static variable get the latest value in the deserialization program.