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 are the topics in core java?
Write a code to show a static variable?
do I need to use synchronized on setvalue(int)? : Java thread
Explain list interface?
What is externalizable?
What are the operands of instanceof operator?
What are the various access specifiers in java?
Explain differences between checked and unchecked exceptions in java?
what is session facade ?
What is the range of the char type?
Which keyword specify that a variable is effectively final ?
Can we sort a map in java?