» » Marker Interfaces in java

Marker interface:

  • The interfaces using which we explicitly mention or mark certain properties to the object are known as marker interface.
  • An interface that is used to check / mark / tag the given object is of a specific type to perform a special operations on that object.
  • Marker interfaces will not have methods , they are empty interfaces.

 Need of marker interface: 

  • It i used to check , whether we can perform some special operations on the passed object
  • For ex: using serializable  interface we can explicitly mention that object of a class is transferable. else it can not.
  • If a class is deriving form java.lang.Cloneable interface then that object can be cloned, else it can not
  • In side those particular methods , that method developer will check that the passed object is of type the given interface or not by using "instanceof" operator.


Predefined marker interfaces:

  1. java.lang.Cloneable
  2. java.io.Serializable
  3. java.util.RandomAccess
  4. java.util.Eventlistener
  5. java.rmi.Remote
  6. java.servlet.SingleThreadModel




Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu