Marker interface having no methods right.. then what is the use of marker interface? for what purpose we use marker interface?

Questions by vengal79

Showing Answers 1 - 13 of 13 Answers

tehy are poor mans meta data. do not use unles focred.U is beig usng annotatshons not marker interfaces.metadata is data abut data. like "dis clzz iz seralizable" or "dis clzz is smlly". old teh jav uses it (jav.lng.Serlizable) but it shold not be using in new codings.

  Was this answer useful?  Yes

ram Kulkarni

  • Aug 22nd, 2006
 

yes Marker interfaces do not have any methods or variable.

They are basically used to identify whether an object is an instance of a particular class. Based on the scenario you can do whatever u want...:)

  Was this answer useful?  Yes

   Marker interface's give some extra characterstic to our classes..

   Ex:Serializable, if our class implements from serializable JVM came to know that this class is going to be serializable.

But Marker interfaces can have method's.

Ex:Runnable interface is a marker interface,But it is having method.It is having 'run' method.

Thanks and Regards...

kishor

  

  Was this answer useful?  Yes

naresh

  • Sep 28th, 2006
 

No, Marker Interface contain no methods

This is standard.

  Was this answer useful?  Yes

colefan

  • Oct 16th, 2006
 

Maker interface ,identify a class to an interface,

and with interface we can impliment multiply inheritance !

  Was this answer useful?  Yes

amitabh26d

  • Aug 26th, 2009
 

Marked interfaces is for compiler use and we need not have to worry about its implementation.  Yes it does not have any methods, it is because by implementing marked interfaces we are telling a compiler that it can optimise this class as per the specification of Java for that interfaces.

  Was this answer useful?  Yes

It is used to identify class.
In the read project, there are so many classes. It can identify that which class belongs to which module

Exmaple :
Cloneable interface can be cloned.  The Java compiler checks to make sure that if the clone() method is called on a class and the class implements the Cloneable interface

TestObject o = new TestObject();
TestObject ref = (TestObject)(o.clone());

If the class TestObject does not implement the interface Cloneable (and Cloneable is not implemented by any of the superclasses that TestObject inherits from), the compiler will mark this line as an error. This is because the clone() method may only be called by objects of type "Cloneable." Hence, even though Cloneable is an empty interface, it serves for identify purpose

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions