It is the concept of transferring the objects (data) of classes from the RAM to any other location outside the RAM. To get Serialization Homework Help contact tutorspoint.com
- Transferring state of an object from RAM to hard disk.
- Transferring the state of an object from RAM to a storage device in another system with the help of network.
We can’t transfer objects of all classes from RAM to other locations outside RAM.
- There is an interface by name serializable. It is a zero-body interface i.e. it has no function definitions.
- Object of classes which implement serializable. Interface only, are eligible for serialization.
- Object output stream class helps us in transferring the objects of classes from our program (i.e. RAM) to other locations.
- Similarly object input stream class helps us in transferring the objects of classes from other locations to our program.
- Object output stream class has a method by name write object (). It takes, object of a class which implements serializable interface, as an argument or in other words, it takes the sertilizable interface reference which points to the object of a class that implements this interface, as an argument.
- The object of object output stream class on which the write object () method is called holds the address of the destination location to which the object is to be transferred.
File output stream fos = new fileoutput stream (“file1.obj”);
Object output stream oos = new object output stream (FOS);
Oos.write object (serializable s)
A a1 = new A ();
In the above example, object of file output stream, fos contains the address of the file which is present in the hard disk. Fos is made available to object of object output stream class oos. Now on oos we call write object () method. In this way address of the destination is made available to write object () method in which the object is to be written. We can’t transfer objects of all classes from RAM to other locations outside RAM.