How is serialization implemented in Java

Showing Answers 1 - 20 of 20 Answers

Ashutosh Gupta

  • Jun 26th, 2005
 

A particular class has to implement an Interface java.io.Serializable for implementing serialization.

Mahesh

  • Jul 27th, 2005
 

What is serialization

  Was this answer useful?  Yes

satyendra chaudhary

  • Jul 30th, 2005
 

Implementing Serializable marks the class as being capable of conversion into a self-describing byte stream that can be used to reconstruct an exact copy of the serialized object when the object is read back from the stream.  

  Was this answer useful?  Yes

Gags

  • Aug 12th, 2005
 

Serialization means saving the State of an Object. It is saved in a file.

  Was this answer useful?  Yes

serialization is process of writing a state into byte stream

ex:

import java.io.serialize;

....//

FileOutputStream f=new FileOutputStream("rajendra.ser");

ObjectOutputStream o=new ObjectOutpuptStream(f);

o.writeObject(f);

o.fush();

  Was this answer useful?  Yes

parimmallarekha

  • Jun 24th, 2006
 

serialization is implemented by java.lang.seriaizable interface it does not have any methods so it is tagged interface.

it means transferring object in to the byte form for maintaing persistance within object. restoring the object is done by deseralization.

   

  Was this answer useful?  Yes

ganeshh

  • Mar 29th, 2007
 

Serialization is the process of writting the state of a object to a linear byte stream.It can be done by implementing the javax.io.serializable interface.In general every interface contains undefined methods.But here in serializable interface we will not have any methods.so,it is called as Marker or Tagged interface.

  Was this answer useful?  Yes

Sachin

  • Apr 17th, 2007
 

By either implementing the Serializable or Externalizable interface. If your object implements the Externalizable interface, you have to override readExternal and writeExternal. These methods give you finer control over how the state of an object is stored on a stream. The writeObject() method triggers the writeExternal and the readObject invokes the readExternal methods on this interface.

In case a parent class is not serilizable but the child class is, then the parent class's members have to be serialized manually in the overridden readExternal and writeExternal methods.

  Was this answer useful?  Yes

arunbharatram

  • May 17th, 2007
 

serialization:

Saving Object's state to a sequence of bytes. Objects can be serialized to files like .txt, .xml etc.

ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("serialize.txt"));

  out.writeObject(objectName);

  out.close();

XMLEncoder out = new XMLEncoder(new BufferedOutputStream(
    new FileOutputStream("serialize.xml")));
  out.writeObject(objectName);
  out.close();

In the first case the class which you want to serialize has to implement serializable interface and also should have a constructor  (since during serialization the values of the datamemebers are saved to the file) but in case of the second one the class which has to be serialized should implement the interface serializable, also should have a default constructor and finally it should have the getter and setter methods complying to java bean standards (since during serialization the values of the datamembers are saved to the file based on the methods).

  Was this answer useful?  Yes

Rajesh G

  • Aug 3rd, 2007
 

Serialization is the mechanism of converting the state of an object to stream of bytes to a persistant storage area(file). By making an object serializable we are making the object as network enabled.

Rajesh

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions