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 modifiers may be used with an inner class that is a member of an outer class in java programming?
Can array grow dynamically in java?
Why runnable interface is used in java?
Explain about strings in java?
What are different types of arrays?
What is parsing a sentence?
What do you mean by flow of struts?
Explain yield() method in thread class ?
Which is bigger double or float?
What are class types in java?
If a method is declared as protected, where may the method be accessed?
Why is java called the platform independent programming language?
What does compareto () do in java?
What is the replace tool?
23. Storage space in java is of the form Stack Queue Heap List 24. What is java code embedded in a web page known as Applets Servlets scriptlets snippets 25. Which of the following attributes are compulsory with an