1.

List Few Differences Between Serializable And Externalizable In Java?

Answer»

Serializable:

  • Serializable has its own default serialization process, we just need to implement Serializable interface. We can customize default serialization process by DEFINING following methods in our class, readObject() and writeObject().Note: We are not OVERRIDING these methods, we are defining them in our class.
  • This is a MARKER interface, does not have any methods.
  • Constructor is not CALLED during deSerialization.

Externalizable:

  • Override writeExternal() and readExternal() for serialization process to happen when implementing Externalizable interface.
  • This has 2 methods readExternal and writeExternal, HENCE it is not a marker interface.
  • Constructor is called during deSerialization.

Serializable:

Externalizable:



Discussion

No Comment Found