Marker Interface and some example for Marker Interface

Marker Interface are those which has no methods or Fields in it. They are called as Empty Interface.

But Implementing them will give special permission to the class to perform certain functionality.

Some example for Marker Interface are

  • Cloneable Interface
  • Serializable Interface
  • Remote Interface

Cloneable Interface

When a class implements this interface, then it has the permission to clone the object using the clone() method of Object class.

If we fail to override the clone method after implementing cloneable interface then it may lead to cloneNotSupportedException.

Serializable Interface

Serialization is used to save the state of the Object so that it can used in some other class by deserializing.
Inorder to achieve this fucntionality, the class should implement this interface.

Remote Interface

An object that is stored on one computer but accessed from another computer is referred to as a remote object. Therefore, we must flag an object with the Remote interface in order to make it a remote object.

Here, the term "Remote interface" is used to describe interfaces whose methods can be called from a virtual machine that is not local. 

Any remote object must implement this interface either directly or indirectly.


Comments

Popular posts from this blog

Why Pointers are Eliminated in Java?

What is the advancement made in Hashmap in Java 8?

Integer.parseInt(“text”)