How to create own Marker Interface with example

Showing Answers 1 - 3 of 3 Answers

R B

  • Nov 28th, 2005
 

 Marker interface example-

public interface Serializabale {}

public interface Cloneable {}

Also known as 'Tagging' interface.

  Was this answer useful?  Yes

1.>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

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