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 are streams?
Why super is first line in java?
What is vector?
What are the states of thread in java?
Why local variables are stored in stack?
What is the best definition for data?
Can we pass a primitive type by reference in java? How
Are arrays primitive data types?
Are constructors methods?
how its run?
What do you mean by boolean?
What is a data structure java?
make a method which any number and any type of argument and print sum of that arguments.....
What language is an assembler written in?
What are conditionals and its types?