Marker interface is an empty interface (no field or methods). Examples of marker interface are Serializable, Clonnable, Remote and ThreadSafe interfaces.
Note: Marker interface is used to inform the JVM that the classes implementing them will have some special behavior.
In java we have following four major marker interfaces:
- Searilizable interface
- Cloneable interface
- Remote interface
- ThreadSafe interface
public interface Serializable { // nothing here }
Q. Marker interface won't contain any method then how the objects will get that special ability?
Ans. JVM is responsible to provide required ability in marker interfaces
No comments:
Post a Comment