1.

Marker Interface in Java

Answer»

An empty interface that contains no fields or methods is known as a marker interface. Realistic examples of a marker interface are Serializable interface, Cloneable interface and Remote interface. Details about these interfaces are given as follows:

Serializable Interface

The serializable interface makes an object eligible to save its state in a file. This interface is stored in the java.io package. The CLASSES in which the serializable interface is not implemented do not have their states SERIALIZED or deserialized.

Cloneable Interface

The cloneable interface is implemented by a class that indicates it is allowed for a clone() method in the Object class to MAKE field-to field COPY of the class instances. The java.lang package contains the cloneable interface.

The exception CloneNotSupportedException is thrown if the clone() method is invoked for a class that has no implementation of the cloneable interface. The classes that have an implementation of this interface usually override the Object.clone() method by convention.

Remote Interface

An object that is stored on a machine and can be accessed from another machine is known as a remote object. The remote interface is required to flag an object and convert it into a remote object. The java.rmi package contains the remote interface.

The interfaces whose methods can be invoked using a non-local virtual machine can also be identified by the remote interface. Also, the Remote Method Invocation (RMI) has some convenience class that can be extended using the remote object implementations and these facilitate the creation of the remote objects.



Discussion

No Comment Found