'Serializable' is a marker interface. A marker interface is one that has no methods. By implimenting a marker interface, you're telling the JRE that your class has specific properties. For example, if your class implements Serializable, then the JRE knows that it doesn't have to do anything special to serialize it. (convert an object of your class into a byte stream) Hope this helps.
For permanent storage of object details (Object State) outside the program scope (i.e. store to a file/ pass the object across the network) we implement the class with Serializable marker interface as follows.
Generally, basic data types can be literally stored into any file permanently, when it comes to object state, Java provides an inbuilt way of storing the instance variables of the objects to any stream using Serializable Interface.
Originally posted by Ritika Agarwal: If I have an employee object and want to store it in database, do I need to serialize employee object?
That would be one way, but not the only way, to do it.
Just one common example: serialization is often used to save and migrate user sessions in a servlet container. Imagine you have a whole server farm with machines A, B, C, and D. Machine A handles a request, and after the request, stores the user session into a file on a shared disk using serialization. Machine C gets the next request from that user, so loads the session and services the request. It's easy, simple, and doesn't require the server to know anything about what's in the session.
"Object-relational mapping". If you have a large number of instances of class X to store, then you can define a database table X with columns that correspond to the fields of X. To store an object, you create a new row in the table, saving each field into the apropriate column. To retrieve an object, you create an empty one, and store the data from one row in the table into its fields.
There exist many software packages that do this automatically -- Hibernate is a very well known one.