How do we make a class serialize?

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can singleton class be inherited in java?

513


What is use of super keyword in java?

592


Can bool be null?

516


What is use of set in java?

486


Write java program to reverse string without using api?

543






Which is better arraylist or vector?

565


Explain importance of inheritance in java?

602


Which method must be implemented by all threads?

717


What is data type example?

543


What are the common uses of "this" keyword in java ?

567


What is a java list?

573


How dead lock situation occurs in java and how you can identify it?

538


What are different types of classloaders?

584


What is the size of an array?

547


Is array serializable java?

515