39 - How Inheritance Affects Java Serialization - Code Demo 1

@backstreetbrogrammer -------------------------------------------------------------------------------- Chapter 16 - How Inheritance Affects Java Serialization - Code Demo 1 -------------------------------------------------------------------------------- If a superclass is Serializable, then all subclasses are automatically Serializable without having to explicitly mark the subclass as Serializable. If a class does NOT explicitly extend any other class and does NOT implement Serializable, then we can confirm that the class is NOT serializable as class Object does NOT implement Serializable. Now suppose a subclass implements Serializable but the super class does NOT. How is this going to affect serialization? When an object is constructed using new (as opposed to being deserialized), following things happen in this sequence: 1. All instance variables are assigned default values - like int as 0, double as 0D, boolean as false , String as null, etc. 2. The const
Back to Top