Hi all,can any one of u clarify,what is the marker interface and what is the use of itthanks in advance

Showing Answers 1 - 3 of 3 Answers

Hasan

  • Oct 24th, 2005
 

Marker Interface is an Interface which contains no methods.Ex : Remote Interface, Serializable Interface etc. If a class implements this class, the class will have the behavior of the interface.

  Was this answer useful?  Yes

nagaraju .Michennametla(inetsolv)

  • Nov 30th, 2005
 

in general tagged or marker interface is used to just identify the class, in real time projects there are so many classes,in order to identify which class belongs to which module,this tag or marker interface is useful.2.>in serialization also,if we want to serialize the object,first it will internally checks whether the class is implementing java.io.serializable interface by using instanceof operator.3.>in rmi also every remote class should implement java.rmi.remote interface.public interface csedept{}public class computer implements csedept{int no;String name;}public class Sample{computer c=new computer();if(c instanceof csedept){c.name="computer science course";}}

  Was this answer useful?  Yes

suryainv

  • Jul 13th, 2007
 

Marker interface is a tag interface
The sub classes of this type of interfaces are identified as the classes pertaining to a particular hierarchy which are having identical characteristics:
It indicates the ability of a class such as Serializable, Remotely accessible, Clonnable, Observable, Runnable etc
How a function can identify that a particular class instance is passed as argument into it be verified is an instance of valid class class hierarchy?
That means how to achieve compile time safe type casting?
Provided if the argument passed in the method is verified and found if the class is an instance of a particular class accept it, otherwise NO.

Note:
Not only the interfaces which are not having methods are called as Marker interfaces
There are Marker interfaces with function as well
But interface which doesn't have any method will only be used for marking
and some interfaces with methods also does the same


  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