Hi, We all know that, marker or tag interface such as "Serializable" does not have either data members or member functions. Then what is the use of implementing such interfaces, when we dont have any member functions to change the behaviour of marker interface. I would be thankful to you, if u could give me proper reason for this. Because I have been looking for this answer for more then 6 months.
The reason you have been looking for so long is because there is no answer - at least, not a legitimate one. There is some fancy reiteration of what appears in literature, but as you may be suspecting, the reasoning and/or explanation is incredibly flawed. If you are prepared to conjecture that there is no answer (as I am proposing), it might help then to pose the question to yourself, "Why shouldn't a marker interface ever be used?".
A marker interface is used more for information than anything else. By saying that your class implements serializable you are telling other code that it contains only member variables which can be serialized (or are transient). That allows your other code to ensure that it only accepts serializable instances.
For example, if you are sending an object as a JMS message inside ObjectMessage then it must be serializable so that it can be sent successfully. This can be checked at compile time.
Having said that there are some issues - you can declare a class to be Serializable when, in fact, it isn't. This problem would not be found until run time. Also, if you declare a class to be serializable and then you extend that class then your child class also implements Serializable and you can't prevent that.
Marker interfaces are useful when you want to give compile time information about the type of class this is when no methods are required. So, you might have a Shape marker interface which is implemented by Square and Circle but not actually share any methods.
On your way in you may have missed that JavaRanch has a policy on display names, and yours does not comply with it; specifically, a first name and a last name are required. Please adjust it accordingly, which you can do right here. Thanks for your prompt attention to this matter.-
As to your question, it comes up frequently. A search through the old posts will bring up many discussions, and a search of the FAQ will find this page. [ June 20, 2006: Message edited by: Ulf Dittmer ]