This set of Java Multiple Choice Questions & Answers (MCQs) on “Serialization – 2”.
1. How an object can become serializable? Answer: b 2. What is serialization? Answer: a 3. What is deserialization? Answer: b 4. How many methods Serializable has? Answer: d 5. What type of members are not serialized? Answer: c 6. If member does not implement serialization, which exception would be thrown? Answer: c 7. Default Serialization process cannot be overridden. Answer: b 8. Which of the following methods is used to avoid serialization of new class whose super class already implements Serialization? Answer: a 9. Which of the following methods is not used while Serialization and DeSerialization? Answer: c 10. Serializaed object can be transferred via network. Answer: a
a) If a class implements java.io.Serializable class
b) If a class or any superclass implements java.io.Serializable interface
c) Any object is serializable
d) No object is serializable
Clarification: A Java object is serializable if class or any its superclass implements java.io.Serializable or its subinterface java.io.Externalizable.
a) Turning object in memory into stream of bytes
b) Turning stream of bytes into an object in memory
c) Turning object in memory into stream of bits
d) Turning stream of bits into an object in memory
Clarification: Serialization in Java is the process of turning object in memory into stream of bytes.
a) Turning object in memory into stream of bytes
b) Turning stream of bytes into an object in memory
c) Turning object in memory into stream of bits
d) Turning stream of bits into an object in memory
Clarification: Deserialization is the reverse process of serialization which is turning stream of bytes into an object in memory.
a) 1
b) 2
c) 3
d) 0
Clarification: Serializable interface does not have any method. It is also called a marker interface.
a) Private
b) Protected
c) Static
d) Throwable
Clarification: All static and transient variables are not serialized.
a) RuntimeException
b) SerializableException
c) NotSerializableException
d) UnSerializedException
Clarification: If member of a class does not implement serialization, NotSerializationException will be thrown.
a) True
b) False
Clarification: Default serialization process can be overridden.
a) writeObject()
b) readWriteObject()
c) writeReadObject()
d) unSerializaedObject()
Clarification: writeObject() and readObject() methods should be implemented to avoid Java serialization.
a) readObject()
b) readExternal()
c) readWriteObject()
d) writeObject()
Clarification: Using readObject(), writeObject(), readExternal() and writeExternal() methods Serialization and DeSerialization are implemented.
a) True
b) False
Clarification: Serialized object can be transferred via network because Java serialized object remains in form of bytes which can be transmitted over network.
