Marker Interface in java is an interface with no fields or methods within it. It is used to convey to the JVM that the class implementing an interface of this category will have some special behaviour. Hence, an empty interface in java is called a marker interface. Marker interface is also called tag interface by some java gurus.
Let's see a program what exactly a marker interface is :
class MarkerDemo implements P
public static void main(String args)
MarkerDemo obj=new MarkerDemo();
if(obj instanceof P)
Here the object obj is created by MarkerDemo class which is also indirectly created by the interface P. Suppose I don’t want to print hello directly by calling show() method, I need some permission, that’s why we give some permission to the class MarkerDemo. If the object obj is the instance of P, then the method show() is called, otherwise else statement will be executed. So here if condition is true so the output is JavaRace.
Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects
SILAN Technology, BBSR Call to: 9439202111 | 9658317757 | 0674-2361252