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 |
Give the hierarchy of inputstream and outputstream classes.
A abstract class extending an abstract class.Super class has both abstract and non-abstract methods.How can we implement abstract and non-abstract mehtods? Explain with snippet
What happens when a thrown exception is not handled?
What data type is string java?
Is string a data type in java?
we cannot create an object of interface but we can create a variable of it
What is meant by object oriented programming – oop?
When you Click a Button, What event will be fired?
What does || || mean in math?
what are the application of compiler and interpreter for source program
What is the method used to get the absolute value of a number?
What is java ceil?