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 |
why operator overloading is removed in java?
Is null false in java?
What is starvation?
What is a parameter in java?
How to create an instance of a class if the class has private constructor?
What is meant by JVM? Is JVM platform independent or not?
What is unicode used for?
What does pointer mean?
what is the significance of listiterator in java?
Can a class have 2 constructors?
What is the superclass of exception?
How do you implement polymorphism in our day to day life?