top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is marker interface in java?

+1 vote
292 views
What is marker interface in java?
posted Dec 8, 2017 by Jon Deck

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

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

Hence, an empty interface in java is called a marker interface. Marker interface is also called tag interface by some java gurus. In java we have the following major marker interfaces as under:

Searilizable interface

Cloneable interface

Remote interface

ThreadSafe interface

The marker interface can be described as a design pattern which is used by many languages to provide run-time type information about the objects. The marker interface provides a way to associate metadata with the class where the language support is not available.

A normal interface specifies functionality which an implementing class must implement. But a marker interface does not follow that pattern. On the other side, the implementing class defines the behavior. There are some hybrid interfaces which act as a marker interface along with some methods. But this type of design is confusing if not handled carefully.

answer Dec 8, 2017 by Manikandan J
...