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
What is a variable and constant?
Difference between throw and throws?
How do you sort an array in java?
What is a void in java?
Describe the process as to how substring() methodology mechanisms in java.
Explain the difference between the public, private, final, protected, and default modifiers?
What is arraylist e in java?
What is the basic of java?
Can an interface have a constructor?
What is class??
What is logical variable?
What happens if constructor is private?
What is an argument java?
What are the common uses of "this" keyword in java ?
What is string substring?