Serialization


  1. How an object can become serializable?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

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


  1. What is serialization?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Serialization in Java is the process of turning object in memory into stream of bytes.



  1. What is deserialization?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

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


  1. What will be printed to the output and written to the file, in the below program?
    import java.io.*;  
    public class FileOutputStreamExample
    {
    public static void main(String args[])
    {
    try
    {
    FileOutputStream FOS = new FileOutputStream("D:\\InterviewMania.txt");
    String str="Welcome to the Interview Mania.";
    byte q[]=str.getBytes();//converting string into byte array
    FOS.write(q);
    FOS.close();
    System.out.println("Success");
    } catch(Exception e){System.out.println(e);}
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    First, it will print “Success” and besides that it will write “Welcome to the Interview Mania” to the file InterviewMania.txt.



  1. What type of members are not serialized?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    All static and transient variables are not serialized.