Java Questions & Answers – Serialization – 2

This set of Java Multiple Choice Questions & Answers (MCQs) focuses 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
View Answer

Answer: b
Explanation: 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
View Answer

Answer: a
Explanation: 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
View Answer

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

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

Answer: d
Explanation: 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
View Answer

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

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

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

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

Answer: b
Explanation: Default serialization process can be overridden.
advertisement

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()
View Answer

Answer: a
Explanation: 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()
View Answer

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

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

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

Sanfoundry Global Education & Learning Series – Java Programming Language.

To practice all areas of Java language, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.