Core java interview questions on Serialization



1.What is serialization?
Serialization is the process of converting Object state to a byte stream so that the byte stream can be reverted back into a copy of the object. A Java object is serializable if its class or any of its superclasses implements either the java.io.Serializable interface or its subinterface, java.io.Externalizable.

2.What De-serialization?
Deserialization is the process of converting the serialized form of an object back into a copy of the object.

3.What is transient keyword?
Java transient keyword is used in serialization. If you define any data member as transient, it will not be serialized.

4.What is Externalizable?

Externalizable is an interface that enables you to define custom rules and your own mechanism for serialization. Serializable defines standard protocol and provides out of the box serialization capabilities. Externalizable extends Serializable

5.Differences between Serializable and Externalizable interface in Java?
 1. In case of Serializable, default serialization process is used. while in case of Externalizable custom Serialization process is used which is implemented by application.
 2. JVM gives call back to readExternel() and writeExternal() of java.io.Externalizalbe interface for restoring and writing objects into persistence.
3. Externalizable interface provides complete control of serialization process to application.
4. readExternal() and writeExternal() supersede any specific implementation of writeObject and readObject methods.

5.Externalizable interface is fast and also consumes less memory as compared to the other one.




Related Post

Comments


©candidjava.com