Java - Things to know before your OCJP exam - Serialization

1. Serializable is a marker interface i.e a class need not override any method if it implements serializable interface.

2. A Class should be declared serializable if its serializing or deserializing. In case a class has objectOutputStream.readObject() or objectOutputStream.writeObject(), it should be declared serializable.

3. ObjectOutputStream and ObjectInputStream wraps the FileInputStream and FileOutputStream respectively.

4. An Object can be serialized only if all of the composed objects are also either serializable or declared transient.

5. If we want any of the instance variable not to be serialized, we should declare it transient.

6. static variables are never serialized.

7. If a parent class is declared serializable , all its derived classes intrinsically becomes serializable. 

8. Object Class is not serializable.

9. If you serialize a collection , all its elements should be serializable.

10. Collection Interfaces are not serializable but all concrete classes are.