Serialization and Networking Mcqs
Our collections of Multiple choice questions and answers focuses on study of ” Serialization and Networking “. These questions are chosen from a collection of most authoritative and best reference books on Java. Our aim is to prepare an individual for competitive exams like NTS, GAT, ECAT, University and College entrance exams and various tests and job interviews. One should practice our Mcqs to assimilate Java Serialization and Networking comprehensively.
Java Programming Mcqs
- Data Types Variables and Arrays Mcqs
- Exception Handling in Java Mcqs
- Interfaces and Packages Mcqs
- Java Classes and Methods Mcqs
- Java Event Handling Mcqs
- Java Inheritance Mcqs
- Java IO and Applets Mcqs
- java lang and java io Mcqs
- Java Language Fundamentals Mcqs
- Java Operators and Control Statements Mcqs
- java utilities Mcqs
- Miscellaneous Topics in Java Mcqs
- Multithreading in Java Mcqs
- Serialization and Networking Mcqs
- Session Management and JSP and Servlet Mcqs
- String Handling
Computer MCQS
Sciences MCQS
2.
How many methods Serializable has?
1
2
3
0
3.
What type of members are not serialized?
Private
Protected
Static
Throwable
4.
If member does not implement serialization, which exception would be thrown?
RuntimeException
SerializableException
NotSerializableException
UnSerializedException
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
5.
Which of the following methods is used to avoid serialization of new class whose super class already implements Serialization?
WriteObject()
ReadWriteObject()
WriteReadObject()
UnSerializaedObject()
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
6.
Which of the following methods is not used while Serialization and DeSerialization?
ReadObject()
ReadExternal()
ReadWriteObject()
WriteObject()
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
7.
Which of these is a process of extracting/removing the state of an object from a stream?
Serialization
Externalization
File Filtering
Deserialization
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
8.
Which of these process occur automatically by java run time system?
Serialization
Memory allocation
Deserialization
All of the mentioned
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
9.
Which of these interface extends DataInput interface?
Serializable
Externalization
ObjectOutput
ObjectInput
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
10.
Which of these is a method of ObjectInput interface used to deserialize an object from a stream?
Int read()
Void close()
Object readObject()
Object WriteObject()
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
11.
Which of these class extend InputStream class?
ObjectStream
ObjectInputStream
ObjectOutput
ObjectInput
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
12.
What is the output of this program?
import java.io.*;
class streams
{
public static void main(String[] args)
{
try
{
FileOutputStream fos = new FileOutputStream("serial");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeInt(5);
oos.flush();
oos.close();
}
catch(Exception e)
{
System.out.println("Serialization" + e);
System.exit(0);
}
try
{
int z;
FileInputStream fis = new FileInputStream("serial");
ObjectInputStream ois = new ObjectInputStream(fis);
z = ois.readInt();
ois.close();
System.out.println(x);
}
catch (Exception e)
{
System.out.print("deserialization");
System.exit(0);
}
}
}
import java.io.*;
class streams
{
public static void main(String[] args)
{
try
{
FileOutputStream fos = new FileOutputStream("serial");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeInt(5);
oos.flush();
oos.close();
}
catch(Exception e)
{
System.out.println("Serialization" + e);
System.exit(0);
}
try
{
int z;
FileInputStream fis = new FileInputStream("serial");
ObjectInputStream ois = new ObjectInputStream(fis);
z = ois.readInt();
ois.close();
System.out.println(x);
}
catch (Exception e)
{
System.out.print("deserialization");
System.exit(0);
}
}
}
5
Void
Serialization
Deserialization
13.
What is the output of this program?<br/>
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;
}
}
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;
}
}
-7
Hello
2.1E10
Deserialization
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
14.
Which of these package contains classes and interfaces for networking?
Java.io
Java.util
Java.net
Java.network
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
15.
Which of these is a protocol for breaking and sending packets to an address across a network?
TCP/IP
DNS
Socket
Proxy Server