can write code for serialization ?
Answer / 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 |
What is the meaning of nullable?
What is token in java?
'A class is a template for an object' explain this statement.
0 Answers Akamai Technologies,
Explain naming conventions for packages?
What are blocks?.
what's diff between struts 1.1 & 1.2
what is ABSTRACTION and what are using in real time project?
State differences between C and Java?
0 Answers Deloitte, JPMorgan Chase,
What is a stream? what are the different types and classes of Streams?
Is vector synchronized in java?
Similarity and difference between static block and static method ?
What does this () mean in constructor chaining concept?