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
What is the final method?
What is the abstraction?
What are the features in java?
How many JVMs can run on a single machine and what is the meaning of Just-In-Time (JIT) compiler?
Write a program in java to find the maximum and minimum value node from a circular linked list.
How do you sort words in java?
What is string subsequence method?
How listener identify that the event came from a particular object?
Can java inner class be static?
what is function overloading in java?
Can static methods be inherited?
What makes a function well defined?
Explain the available thread states in a high-level?
What is the similarity between dynamic binding and linking?
What is instance means in java?