250+ TOP MCQs on Serialization – 2 and Answers

This set of Java Multiple Choice Questions & Answers (MCQs) on “Serialization – 2”.

1. How an object can become serializable?
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

Answer: b
Clarification: A Java object is serializable if class or any its superclass implements java.io.Serializable or its subinterface java.io.Externalizable.

2. What is serialization?
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

Answer: a
Clarification: Serialization in Java is the process of turning object in memory into stream of bytes.

3. What is deserialization?
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

Answer: b
Clarification: Deserialization is the reverse process of serialization which is turning stream of bytes into an object in memory.

4. How many methods Serializable has?
a) 1
b) 2
c) 3
d) 0

Answer: d
Clarification: Serializable interface does not have any method. It is also called a marker interface.

5. What type of members are not serialized?
a) Private
b) Protected
c) Static
d) Throwable

Answer: c
Clarification: All static and transient variables are not serialized.

  250+ TOP MCQs on Java.util – Vectors & Stack and Answers

6. If member does not implement serialization, which exception would be thrown?
a) RuntimeException
b) SerializableException
c) NotSerializableException
d) UnSerializedException

Answer: c
Clarification: If member of a class does not implement serialization, NotSerializationException will be thrown.

7. Default Serialization process cannot be overridden.
a) True
b) False

Answer: b
Clarification: Default serialization process can be overridden.

8. Which of the following methods is used to avoid serialization of new class whose super class already implements Serialization?
a) writeObject()
b) readWriteObject()
c) writeReadObject()
d) unSerializaedObject()

Answer: a
Clarification: writeObject() and readObject() methods should be implemented to avoid Java serialization.

9. Which of the following methods is not used while Serialization and DeSerialization?
a) readObject()
b) readExternal()
c) readWriteObject()
d) writeObject()

Answer: c
Clarification: Using readObject(), writeObject(), readExternal() and writeExternal() methods Serialization and DeSerialization are implemented.

10. Serializaed object can be transferred via network.
a) True
b) False

Answer: a
Clarification: Serialized object can be transferred via network because Java serialized object remains in form of bytes which can be transmitted over network.

Leave a Comment

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

Scroll to Top