How do we make a class serialize?

Answers were Sorted based on User's Feedback



How do we make a class serialize?..

Answer / javamasque

We have to fallow below steps to serialize an object
1. The object to be serialized need to implement java.io.Serializable / java.io. Externalizable interface.
2. Generate serial version id for that serializable object.
3. ObjectOutputStream is used to write [writeObject(..) or wirteExternal()] object.
4. FileOutputStream is used to persist in flat file.
5. The flat file extension should be (<file-name>.ser)

Is This Answer Correct ?    3 Yes 0 No

How do we make a class serialize?..

Answer / 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

How do we make a class serialize?..

Answer / javamasque

Here is the updated answer
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. 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.
5. ObjectOutputStream is used to write [writeObject] object.
6. FileOutputStream is used to persist in flat file.
7. The flat file extension should be (<file-name>.ser)

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

how to open and edit XML file in Weblogic???

0 Answers   Symphony,


What is hashing principle in java?

0 Answers  


What access modifiers can be used for class ?

0 Answers  


What is the tradeoff between using an unordered array versus an ordered array?

0 Answers  


What is reflexive association?

1 Answers   Infogain,






what is the diffrence between class and object?

5 Answers  


What is an Applet ?

2 Answers  


Can I create any Marker Interface? If yes then how can I use it???

4 Answers  


What is use of super keyword?

0 Answers  


briefley expalin about the packages

3 Answers  


What is the symbol for average?

0 Answers  


Can we call the constructor of a class more than once for an object?

0 Answers  


Categories