> Why we need Marker Interface, It doesn't have any methods to implement
> , why we use empty interfaces, how it useful.
Good question. A marker interface provides a way to organize classes
into categories, and derived classes all inherit those categories. Even
though a marker interface does not specify behavior, it does very
strongly specify a type, and that type can be checked by instanceof or a
parameter declaration.
The language designers could have made a requirement that interfaces
specify methods, but that would have been an unneeded constraint. The
marker interface is just a way to take advantage of the type
identification that an interface provides, without declaring any behavior.
Java does not, in my opinion, have the cleanest possible implementation
of this pattern, since if a superclass is declared to implement an
interface, a derived class cannot undo that. There are strong arguments
either way, the other being that subclasses should always implement any
interfaces of their superclasses. Very rare that it's a problem.