Answer Posted / javamasque
We have to fallow below steps to serialize an object
1. The object to be serialized need to implement java.io.Serializable interface.
2. It will use Java’s default serialization mechanism.
3. Generate serial version id for that serializable object.
4. Only default constructor is applicable to all class hierarchy (from child to all super classes if any). It is necessary at deserialization otherwise throw InvalidClassException.
5. Generate serial version UID for all super classes in hierarchy (all super classes if any) otherwise the properties of all its super classes will be assigned to its default value during deserializtion.
6. ObjectOutputStream is used to write [writeObject] object.
7. FileOutputStream is used to persist in flat file.
8. The flat file extension should be (<file-name>.ser)
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
how to one war file class to another war file class?
Is vector thread safe in java?
What is meant by oops concept in java?
What are the advantages and disadvantages of reference counting in garbage collection?
How to print an arraylist in java?
Why does the integer quotient -0/3 yield 0, but the double quotient -0.0/3.0 yields – 0.0?
Tell me a few examples of final classes defined in Java API?
What exactly is java?
What do you mean by stream pipelining in java 8?
Write a java program to print fibonacci series?
Name four container classes.
What are the basic concepts of OOPS in java?
Is singleton a bad practice?
What are byte codes?
Is age discrete or continuous?