Answer Posted / bharat shivram
import java.io.*;
public class SerializationDemo {
public static void main(String args[]) {
// Object serialization
try {
MyClass object1 = new MyClass("Hello", -7, 2.7e10);
System.out.println("object1: " + object1);
FileOutputStream fos = new FileOutputStream("serial");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(object1);
oos.flush();
oos.close();
}
catch(Exception e) {
System.out.println("Exception during serialization: " + e);
System.exit(0);
}
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
How does thread synchronization occurs inside a monitor? What levels of synchronization can you apply?
What are the advantages of arraylist over arrays?
Write a program in java to calculate the difference between the sum of the odd level and even level nodes of a binary tree.
What is the difference between overriding & overloading?
How can we pass argument to a function by reference instead of pass by value?
Which methods cannot be overridden in java?
What will happen when using pass by reference in java?
What is module in project?
What is the difference between array list and vector in java?
Give an example of call be reference significance.
How do you input a string in java?
What is the main use of java?
What is boolean false?
How many bits is a 64 bit byte?
What do heavy weight components mean in java programming?