What Is The Use Of A Marker Interface Even It Doesn't Have Methods In Core Java?


3 Answers

sridher yamsani Profile
sridher yamsani answered
Marker interface plays vital role even though it doesn't contain any methods.The main purpose is to identify the special objects from normal objects for example if you want to serialize an object then how you will inform to the JVM to serialize the particular object because there may be so many objects available in JVM. In order to know which object is to be serialized marker interfaces are used. When you implement a marker interface the object will be tagged with boolean property with that property JVM knows which object should be serialized and which object should not be serialized.
thanked the writer.
Anonymous commented
Marker interfaces are understood by the JVM. The JVM takes care of how to deal with a class that implements that marker interface.
Ramesh Kumar Profile
Ramesh Kumar answered
Java defines these(Tagging or Marker ) interfaces that are just used as a boolea property of a class,But doesn't actually require the implementation of any methods.
These interfaces are called Tagging or Marking Interfaces.
Thank you.
Anonymous Profile
Anonymous answered
Market interfaces are just used to tell the the JVM that, just do specific things which is jvm specific for the objects which implements those interfaces.
Means all the objects which implements marker interface, only jvm is responsible to do the specific functionality.

Answer Question