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

What is the difference between hashmap and hashtable? What is an interface?

494


Difference between string, stringbuffer and stringbuilder?

562


What is an immutable class? How to create an immutable class?

533


How to solve the problem of generating the unique hash keys with hash function?

1453


What are different exception types exceptions available in java ?

471






Give an example of call be reference significance.

602


What is flag in python?

545


What are the types of java?

598


What is an object's lock and which object's have locks in java programming?

561


What is a default constructor and also define copy contrucyor?

593


What is meant by 'Class access modifiers'?

550


What is a cup of java?

552


How do you write methodology?

556


How does list work in java?

500


When is the arraystoreexception thrown?

564