Serialization
- How an object can become serializable?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
A Java object is serializable if class or any its superclass implements java.io.Serializable or its subinterface java.io.Externalizable.
- What is serialization?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Serialization in Java is the process of turning object in memory into stream of bytes.
- What is deserialization?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Deserialization is the reverse process of serialization which is turning stream of bytes into an object in memory.
- What will be printed to the output and written to the file, in the below program?
import java.io.*;
public class FileOutputStreamExample
{
public static void main(String args[])
{
try
{
FileOutputStream FOS = new FileOutputStream("D:\\InterviewMania.txt");
String str="Welcome to the Interview Mania.";
byte q[]=str.getBytes();//converting string into byte array
FOS.write(q);
FOS.close();
System.out.println("Success");
} catch(Exception e){System.out.println(e);}
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
First, it will print “Success” and besides that it will write “Welcome to the Interview Mania” to the file InterviewMania.txt.
- What type of members are not serialized?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
All static and transient variables are not serialized.