Important Questions on Java Serialization Asked in Interviews

  • What is Serialization in Java?
  • How to make a Java class Serializable?
  • What is the difference between Serializable and Externalizable interface in Java?
  • How many methods Serializable interface has? If no method then what is the purpose of Serializable interface?
  • What is serialVersionUID?
  • While serializing you want some of the members not to serialize? How do you achieve it?
  • What will happen if one of the members in the class doesn’t implement Serializable interface?
  • If a class is Serializable but its super class in not, what will be the state of the instance variables inherited from super class after de-Serialization?
  • Can you Customize Serialization process or can you override default Serialization process in Java?
  • Suppose super class of a new class implement Serializable interface, how can you avoid new class to being serialized?
  • Which methods are used during Serialization and de-Serialization process in Java?
  • Suppose you have a class which you serialized it and stored in persistence and later modified that class to add a new field. What will happen if
  • you de-serialize the object already serialized?
  • Can we transfer a serialized object via network?
  • When will you use Serializable or Externalizable interface? and why?
  • What are the ways to speed up Object Serialization? How to improve Serialization performance?
  • What would happen if the SerialVersionUID of an object is not defined?
  • What are transient variables? What role do they play in Serialization process?
  • Why does serialization NOT save the value of static class attributes? Why static variables are not serialized?
  • How to serialize a collection in java? How to serialize a ArrayList, HashMap or HashSet object in Java?
  • Which kind of variables are not serialized during Java Serialization?

You may also like

Leave a Reply

Your email address will not be published. Required fields are marked *