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 inheritance?
What is the need of transient variables in Java ?
what is prepare statement? what is calabedtarement?
What is the use of conditional statement?
What is the is a and has a relation ship in oops concept in java?
they asked class A{} class B{} class c{} all the three class saved as a single file,there is no main method in the file and anothe class M.java class m { psvm(String args[]) { // here the parent class can access } }
2 Answers DNS, IPSR Solutions,
What are different types of constants?
What is treeset and treemap in java?
what is the use of abstract class?
3 Answers Amdocs, Atos Origin, Invictus,
What differences exist between iterator and listiterator?
What is meant by object oriented programming – oop?
What is sortedset in java?