0

I have a lot of confusion on these Questions. Can explain with examples.

I am searching marker interfaces and normal intefaces? some sites give "No methods in interface is called Marker Interfaces" but some sites give Runnable in also Marker Interface. But what is correct answer?

aioobe
  • 413,195
  • 112
  • 811
  • 826
rajasekhar
  • 29
  • 1
  • 3
  • In the end... Marker interface ARE normal interfaces, the only difference with non-marker interfaces, is that they don't provide any methods. At this point in time, they appear less than they used to, because most developers replace them by annotations. – Stultuske May 13 '15 at 13:23
  • *"... some sites give Runnable in also Marker Interface"* - those sites are incorrect. – Stephen C May 13 '15 at 13:29

2 Answers2

0

A marker interface is just like an ordinary interface but without any methods. Serializable is an example of a marker interface.

Since a marker interface doesn't require any methods to be implemented, any class can have implements Serializable. Adding this doesn't do anything except "mark" the class as serializable, thus the term "marker interface".

Despite what other webpages say, Runnable is not a marker interface, since it declares a method called run().

aioobe
  • 413,195
  • 112
  • 811
  • 826
0

Runnable is not a marker a interface as it contains a method.
Interfaces without any methods are marker interfaces.

That's why they are called markers, you just mark the class with that interface
by having the class implement it, you don't impose any functionality on the class.

peter.petrov
  • 38,363
  • 16
  • 94
  • 159