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
Explain the importance of finally over return statement?
What is a pattern what is an anti pattern?
Can a method be overloaded based on different return type but same argument type?
What is procedure writing?
How to sort an unsorted array in java?
What is void keyword?
What is the size of integer?
What is package private scope in java?
What does system.gc() and runtime.gc() methods do?
What is tree in java?
What does substring mean?
What is var keyword ?
What is data movement?
What is a buffer in java?
What is java autoboxing?