Java Stream Question and Answers

13. What are the disadvantage of serialization?
 
  • Since serialization does not offer any transaction control mechanism per se, it is not suitable for use within applications needing concurrent access without making use of additional APIs.
  • It should ideally not be used with large sized objects as it offers significant overhead.
  • Large objects also significantly increase the memory requirements of your application since the object input/output streams cache live references to all objects written to or read from the stream until the stream is closed or reset.
  • The serialization interface does not offer fine grained control over object access although you can somewhat circumvent this issue by implementing the complex Externalizable interface, instead.
 
Your Name Your Email-ID
Your Answer
14. What is the difference between serializable and externalizable interface?
 
  • When you use Serializable interface, your class is serialized automatically by default.
  • But you can override writeObject() and readObject() two methods to control more complex object serialization process.
  • When you use Externalizable interface, you can have a complete control over your class's serialization process.
 
Your Name Your Email-ID
Your Answer
15. What is an I/O filter?
  An I/O filter is an object that reads from one stream and writes to another usually altering the data in some way as it passed from one stream to another.
 
Your Name Your Email-ID
Your Answer
16. What is externalizable?
 
  • Externalizable is an interface which contains two methods readExternal() and writeExternal().
  • Those methods give you a control over the serialization mechanism.
  • Thus, if your class implements this interface, you can customize the serialization process by implementing these methods.
 
Your Name Your Email-ID
Your Answer
123456 Page 4 of 6