2

Possible Duplicate:
What is the use of marker interfaces in Java?

What is the use of extending marker interface.

Community
  • 1
  • 1
Rajesh
  • 8,477
  • 5
  • 20
  • 7
  • 1
    See [What is the use of marker interfaces in Java?](http://stackoverflow.com/questions/1995198/what-is-the-use-of-marker-interfaces-in-java) – Matthew Flaschen May 24 '10 at 09:46

4 Answers4

5

A marker interface is exactly that: A means of marking that a class is or does certain things, even if those things are not expressed as actual methods. Marker interfaces date from very early on; these days while you might use one, you might also look at using annotations instead.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • As a matter of *opinion*, I find marker interfaces a bit of a blunt instrument, and prefer other options. I think I've only ever ended up writing two marker interfaces, in ~12 years of (light) Java development. – T.J. Crowder May 24 '10 at 09:43
4

It is an interface with no methods. It is just used to "mark" Java classes which support a certain functionality like Serializable and Cloneable.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
2

a marker interface is used to add additional information to an object (see for example: http://en.wikipedia.org/wiki/Marker_interface_pattern). I dont know what you mean with extending, but a object implements a marker interface.

for example the serializable interface in java:

A class implements this interface to indicate that its non-transient data members can be written to an ObjectOutputStream

1

Marker interface are having no methods and they just use to identify the liablity of a class at run time, as your class suppose to have implemented B iterface and then at any point u can check instance of your class pertaining to that interface. U can do whatever you want.

Pedantic
  • 1,368
  • 10
  • 39
  • 70