adplus-dvertising

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.

frame-decoration

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

Q1.
Which of these is a process of writing the state of an object to a byte stream?
Discuss
Answer: (a).Serialization
Q2.
Which of these process occur automatically by the java runtime system?
Discuss
Answer: (a).Serialization
Q3.
Which of these is an interface for control over serialization and deserialization?
Discuss
Answer: (b).Externalization
Q4.
Which of these interface extends DataOutput interface?
Discuss
Answer: (c).ObjectOutput
Q5.
Which of these is a method of ObjectOutput interface used to finalize the output state so that any buffers are cleared?
Discuss
Answer: (b).flush()
Q6.
Which of these is method of ObjectOutput interface used to write the object to input or output stream as required?
Discuss
Answer: (d).writeObject()
Q7.
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  
            {
                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;
 }
    }
Discuss
Answer: (a).s=Hello; i=-7; d=2.1E10
Q8.
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;
 }
    }
Discuss
Answer: (d).deserialization
Discuss
Answer: (b).If a class or any superclass implements java.io.Serializable interface
Discuss
Answer: (a).Turning object in memory into stream of bytes
Page 1 of 9

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!