First, the question - is Externalizable covered on the
SCJP exam?
I've tried to come up with a list of rules for Serializing classes. Are they accurate? Is anything missing?
An object is serializable if and only if its class or its superclass implements the Serializable or Externalizable interface.
A subclass is serializable even if its superclass is not:
The class MUST impl Serializable.
First superclass in the hierarchy of the serializable class that does not implements Serializable interface, MUST have a no-arg constructor.
If this is violated, readObject() will produce a java.io.InvalidClassException in runtime.
The no-arg contructor of every non-serializable superclass will run when an object is deserialized.
The deserialized object’s constructor does not run when it is deserialized.
The class must be visible at the point of serialization.
All primitive types are serializable.
Transient fields (marked by transient modifier) are NOT serialized.
A Serializable class must mark transient fields of classes that do not support serialization (e.g., a file stream).
Static fields (marked by static modifier) are not serialized.
If member variables of a serializable object reference a non-serializable object, the code will compile but a RumtimeException will be thrown.
Mark