Question
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
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. Which of these package contains classes and interfaces for networking?
View solution
Q. Which of these is a protocol for breaking and sending packets to an address across a network?
View solution
Q. How many bits are in a single IP address?
View solution
Q. Which of these is a full form of DNS?
View solution
Q. Which of these class is used to encapsulate IP address and DNS?
View solution
Q. Which of these interface abstractes the output of messages from httpd?
View solution
Q. Which of these class is used to create servers that listen for either local or remote client programs?
View solution
Q. Which of these methods is used to make raw MIME formatted string?
View solution
Q. Which of these class is used for operating on request from the client to the server?
View solution
Q. Which of these method of MimeHeader is used to return the string equivalent of the values stores on MimeHeader?
View solution
Q. Which of these is an instance variable of class httpd?
View solution
Q. Which of these methods of httpd class is used to read data from the stream?
View solution
Q. Which of these method of httpd class is used to get report on each hit to HTTP server?
View solution
Q. Which of these methods are used to find a URL from the cache of httpd?
View solution
Q. Which of these variables stores the number of hits that are successfully served out of cache?
View solution
Q. Which of these method of httpd class is used to write UrlCacheEntry object into local disk?
View solution
Q. Which of these method is used to start a server thread?
View solution
Q. Which of these method is called when http daemon is acting like a normal web server?
View solution
Q. What does URL stands for?
View solution
Q. Which of these exceptions is thrown by URL class’s constructors?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Java Programming? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!