Welcome to the Serialization and Networking MCQs Page
Dive deep into the fascinating world of Serialization and Networking with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Serialization and Networking, a crucial aspect of Java Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Serialization and Networking, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Java Programming.
Check out the MCQs below to embark on an enriching journey through Serialization and Networking. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Java Programming.
Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Serialization and Networking. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!
Serialization and Networking MCQs | Page 1 of 9
Explore more Topics under Java Programming
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
{
Myclass object2;
FileInputStream fis = new FileInputStream("serial");
ObjectInputStream ois = new ObjectInputStream(fis);
object2 = (Myclass)ois.readObject();
ois.close();
System.out.println(object2);
}
catch (Exception e)
{
System.out.print("deserialization" + e);
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;
}
}
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;
}
}
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!