Javatpoint Logo

what is the use of marker interface?

By: pnsmgl*** On: Sun Jan 27 12:14:23 IST 2013     Question Reputation20 Answer Reputation4 Quiz Belt Series Points0  24Blank User
what is the use of marker interface?Up0Down

 
marker interface is use just for identity n nothing else..

like u use ur college id card just for identity.
Image Created0Down

By: [email protected] On: Mon Jan 28 12:59:01 IST 2013 Question Reputation0 Answer Reputation392 Belt Series Points0 392User Image
Are You Satisfied :2Yes4No
 
Marker interface is used as a tag to inform a message to the java compiler so that it can add special behaviour to the class implementing it. Java marker interface has no members in it.



Lets take the java.io.Serializable marker interface. It doesnot has any members defined it it. When a java class is to be serialized, you should intimate the java compiler in some way that there is a possibility of serializing this java class. In this scenario, marker interfaces are used. The java class which may be serialized has to implement the java.io.Serializable marker interface. In such way, we are intimating the java compiler.

From java 1.5, the need for marker interface is eliminated by the introduction of the java annotation feature. So, it is wise to use java annotations than the marker interface. It has more feature and advantages than the java marker interface.
Image Created0Down

By: [email protected] On: Mon Jan 28 13:01:49 IST 2013 Question Reputation0 Answer Reputation147 Belt Series Points0 147User Image
Are You Satisfied :4Yes2No
 
tanks Mr.rishiImage Created0Down

By: [email protected] On: Mon Jan 28 22:14:20 IST 2013 Question Reputation20 Answer Reputation4 Belt Series Points0 24User Image
Are You Satisfied :1Yes1No
 
Thanx to javatpointImage Created0Down

By: [email protected] On: Sat Apr 27 05:24:44 EDT 2013 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No