Static fields are like the Transient fields and they are not serialized with the object. The reason is that they are associated with the class rather then object's state.
If we have a sub class which extends a super class and implements Serializable interface and super class doesn't implement Serializable interface then:
While serializing the sub class object, only its state excluding the super class visible variables will be serialized.
While de-serializing the sub class state will restored from the serialized data. The super class state will be initialized by invoking the no-arg constructor of super class.
The no-arg constructor should be visible to the sub class otherwise an exception will be thrown at runtime.
If the super class also implements Serializable interface then the state of the subclass object including the super class visible variables will be serialized. And while de-serializing the sub class and super class state will be restored from the serialized data only instead of no-arg constructor for super class.
If there is an arg constructor in the super class and there is no default constructor then the subclass constructor should specify the call to the specific super (arg...) constructor. Otherwise there will be a compile-time error.
Why NoSQL is in fashion?
-
Couple of years back NoSQL was relatively unheard term. It has become a
new buzzword in town, catching people's imagination. Almost all big daddies
of Int...