Thread concurrency Quiz in Java - MCQ (Multiple choice questions) interviews

Serialization and Deserialization Java - MCQ - 20 Multiple choice questions in 1 set



This Quiz consists of Serialization and Deserialization's 20 Multiple choice questions in 1 set - Java Serialization and Deserialization quiz - MCQ

Contents of page >

Serialization and Deserialization Java - MCQ set 1 (20 questions, 48 marks)







Note : Each set consists of 20 questions
Each set consists of 2 EASY level difficulty questions 1 mark each.         1 * 2 = 2 marks
Each set consists of 8 MEDIUM level difficulty questions 2 mark each. 2 * 8 = 16 marks
Each set consists of 10 HARD level difficulty questions 3 mark each.       3 * 10 = 30 marks
So, Each set is TOTAL of 48 marks
This quiz have been designed to check beginners and experienced Java developers skills. Scoring below 14 marks means POOR : You are Java Beginner and need to work very hard. Scoring 14-32 marks means AVERAGE : You know Java basics, but you need more practice. Scoring 32-44 marks means GOOD : You have good Java knowledge. Scoring above 44 marks means EXCELLENT : You have outstanding java knowledge.




Serialization and Deserialization Java - MCQ set 1 (20 questions, 48 marks)



    Q1 - Q2, 2 EASY level difficulty questions 1 mark each. 1 * 2 = 2 marks

  1. What is true about Serializable interface in java?

  2. a.Marker interface
    b.Serializable provides its own default serialization process, we just need to implement Serializable interface
    c.All
    d.None

  3. Externalizable provides which method for reading and writing in java

  4. a.readObject() and writeObject()
    b.writeExternal() and readExternal()
    c.externalWrite() and externalRead()
    d.write() and read()



    Q3 - Q10, 10 MEDIUM level difficulty questions 2 mark each. 2 * 8 = 16 marks

  5. What is invalid about serialization in java?

  6. a.Serialized object can be persisted into database.
    b.Serialized object can't be persisted into file.
    c.Serialization is process of converting object into byte stream
    d.Serialized object can be transferred over network.

  7. What method should we use for writing object in Serialization in java?

  8. a.objectWrite
    b.objWrite
    c.writeObject
    d.write

  9. Can you customize serialization process when you have implemented Serializable interface

  10. a.By defining objectWrite() and objectRead() methods
    b.By defining write() and read() methods
    c.It's not possible
    d.By defining writeObject() and readObject() methods

  11. What is true about serialVersionUID in serialization and deserialization in java?

  12. a.serialVersionUID is used for version control of object
    b.If we don’t define serialVersionUID in the class, and any modification is made in class, then we won’t be able to deSerialize our class
    c.The serialization at runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization.
    d.All

  13. Let's say class does not contain SerialVersionUID, and you have serialized a class & then added few fields in it and then deserialize already serialized version of class, what will happen?

  14. a.InvalidException
    b.InvalidClassException
    c.No exception
    d.InvalidClassCastException

  15. What will happen if one the member of class does not implement Serializable interface in java?

  16. a.NullPointerException
    b.compilation error
    c.NotSerializableException
    d.SerializableNotPossibleException

  17. What is significance of transient variables in serialization and deserialization in java

  18. a.We can initialize transient variables during deSerialization by customizing deSerialization process.
    b.we must mark try to mark all rarely used variables as transient.
    c.Serialization is not applicable on transient variables
    d.All

  19. How can you avoid certain member variables of class from getting Serialized in java?

  20. a.By declaring them transient variable
    b.By declaring them static variable
    c.All
    d.None



    Q11 - Q20, 10 HARD level difficulty questions 3 mark each.       3 * 10 = 30 marks

  21. What are compatible changes in Serialization process in java

  22. a.Adding new fields
    b.Adding writeObject()/readObject() methods
    c.removing writeObject()/readObject() methods
    d.Changing access modifier of a field
    e.All

  23. What are incompatible changes in Serialization process in java

  24. a.changing transient filed to non transient field
    b.Deletion of fields
    c.Changing a field from static to non static
    d.Addition of new fields
    e.Removing writeObject()/readObject() methods

  25. Alternate to serialization process in java?

  26. a.convert object into JSON to transfer the object
    b.convert object into XML to transfer the object
    c.All of these
    d.None of these

  27. What will happen if we try to serialize List, Set and Map as member of class in java?

  28. a.NotSerializableException
    b.They will get serialized
    c.compilation error
    d.SerializableNotPossibleException

  29. What will happen if we try to serialize primitive types in java?

  30. a.They will get serialized
    b.compilation error
    c.SerializableNotPossibleException
    d.NotSerializableException

  31. Is constructor of super class called during DeSerialization process of subclass in java?

  32. a.If superclass has implemented Serializable - constructor is not called during DeSerialization process.
    b.If superclass has not implemented Serializable - constructor is called during DeSerialization process
    c.All
    d.None

  33. What Is valid about constructor call during DeSerialization process in java?

  34. a.If Serializable has been implemented - constructor is not called during DeSerialization process
    b.if Externalizable has been implemented - constructor is called during DeSerialization process.
    c.All
    d.None

  35. How can subclass avoid Serialization if its superClass has implemented Serialization interface in java

  36. a.Not possible, as subclass always inherits all features from its parent class
    b.define writeObject() method and you are done
    c.define writeObject() method and throw NotSerException()
    d.define writeObject() method and throw NotSerializableException()

  37. What will be output of following code in serialization and deserialization in java-


  38. a.Program will execute perfectly
    b.Compilation error
    c.NotSerializableException is thrown
    d.None

  39. Which method can help you serialize Singleton class such that object returned by Deserialization process is in same state as it was during Serialization time in java

  40. a.writeResolve()
    b.resolve()
    c.resolveRead()
    d.readResolve()





Quiz 1 - Correct answers



EASY
1) c
2) b

MEDIUM
3) b
4) c
5) d
6) d
7) b
8) c
9) d
10) c

HARD
11) e
12) b
13) c
14) b
15) a
16) c
17) c
18) d
19) c
20) d

Go to TOP of the page
eEdit
Must read for you :