adplus-dvertising
frame-decoration

Question

What is the output of this program?
    import java.io.*;
    class serialization 
    {
        public static void main(String[] args) 
        {
            try 
            {
                Myclass object1 = new Myclass("Hello", -7, 2.1e10);
         FileOutputStream fos = new FileOutputStream("serial");
         ObjectOutputStream oos = new ObjectOutputStream(fos);
                oos.writeObject(object1);
                oos.flush();
                oos.close();
     }
     catch(Exception e) 
            {
         System.out.println("Serialization" + e);
                System.exit(0);
            }
     try
            {
         int x;
         FileInputStream fis = new FileInputStream("serial");
         ObjectInputStream ois = new ObjectInputStream(fis);
                x = ois.readInt();
                ois.close();
         System.out.println(x);       
     }
     catch (Exception e)
            {
                System.out.print("deserialization");
         System.exit(0);
     }
        }
    }
    class Myclass implements Serializable
    {
 String s;
 int i;
 double d;
        Myclass(String s, int i, double d)
        {
     this.d = d;
     this.i = i;
     this.s = s;
 }
    }

a.

-7

b.

Hello

c.

2.1E10

d.

deserialization

Posted under Java Programming

Answer: (d).deserialization

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?

Similar Questions

Discover Related MCQs

Q. How an object can become serializable?

Q. What is serialization?

Q. What is deserialization?

Q. How many methods Serializable has?

Q. What type of members are not serialized?

Q. If member does not implement serialization, which exception would be thrown?

Q. Default Serialization process cannot be overridden.

Q. Which of the following methods is used to avoid serialization of new class whose super class already implements Serialization?

Q. Which of the following methods is not used while Serialization and DeSerialization?

Q. Serializaed object can be transferred via network.

Q. Which of these is a process of extracting/removing the state of an object from a stream?

Q. Which of these process occur automatically by java run time system?

Q. Which of these interface extends DataInput interface?

Q. Which of these is a method of ObjectInput interface used to deserialize an object from a stream?

Q. Which of these class extend InputStream class?

Q. Which of these package contains classes and interfaces for networking?

Q. Which of these is a protocol for breaking and sending packets to an address across a network?

Q. How many bits are in a single IP address?

Q. Which of these is a full form of DNS?

Q. Which of these class is used to encapsulate IP address and DNS?