32014Sep

What is Marker Interface

Marker interface It is interface that neither have any type of method nor data members. If we implements this interface to any class then JVM add specific code or instruction in class byte code and provide additional behaviour at runtime.Marker interface is heavy process because JVM has to set up completely different task for it,we should always implement marker interface when it is highly required.

Marker interface example:-

Searilizable interface
Cloneable interface
Remote interface
ThreadSafe interface

Commonly used Classes which use Marker interface :- String Class,Proxy Class,File Class,GenericServlet,Java Bean etc.

We can Perform all task by flag, which marker interface is doing.So question arise why we use marker interface.Because Marker interface provide some extra facility like:-

1. It make program more Readable.
2. We can use Ploymorphism.