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
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
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
Explanation: 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
View Answer
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
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
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
Explanation: 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()
View Answer
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
Explanation: Using readObject(), writeObject(), readExternal() and writeExternal() methods Serialization and DeSerialization are implemented.
10. Serializaed object can be transferred via network.
a) True
b) False
View Answer
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]
- Check Java Books
- Practice Programming MCQs
- Apply for Java Internship
- Practice Information Technology MCQs
- Practice BCA MCQs