<p>Personally I think it's a really poor idea: very bad OO design as it splits responsibility.
<p>Probably the most obvious example is with java.lang.Object and java.lang.Clonable: Object has a clone method but it wont work unless the class also implements Clonable.
<p>The way it should have done was to place the clone method on the Clonable interface and have a protected clone helper method on Object. One of several poor OO design decisions in Java I'm afraid (my other big bug bears if you're interested are: deprecated methods are never deleted and pretty much the whole of Java 1.5
clone() is a bad design, but I wouldn't say that marker interfaces in general are always a bad thing.
When a class implements a marker interface X, it's just a way of saying "I support some feature X" which isn't expressed as a set of methods. For example, implementing the java.io.Serializable marker interface is a signal to the JVM that a class will allow itself to be serialized.
Whenever there's a marker interface X, there's code someplace which says
veeramani velayutham wrote:marker interface does not contain method
actually it has...
If an interface has no direct superinterfaces, then the interface implicitly declares a public abstract member method m with signature ss, return type rr, and throws clause t corresponding to each public instance method mm with signature ss, return type rr, and throws clause tt declared in Object, unless a method with the same signature, same return type, and a compatible throws clause is explicitly declared by the interface. It is a compile-time error if the interface explicitly declares such a method m in the case where m is declared to be final in Object.
Pratik Thakare wrote:
if you are using Serializable or clonable interface it means (it indicates) that your class object are is serializable or clonable.
If a class implements Serializable and it dont contain any other object which is not serializable, then yes, its object can be serializable
Serialization is a deep copy process. so all object references from the object also should be Serializable.