How does marker interface provides functionality to the
implemented class ?

or How dose maker interface gets the functionalities as
serialization or cloning.

Answer Posted / qim2010

In java language programming, interfaces with no methods are
known as marker interfaces. Marker interfaces are
Serializable, Clonable, SingleThreadModel, Event listener.
Marker Interfaces are implemented by the classes or their
super classes in order to add some functionality.

e.g. Suppose you want to persist (save) the state of an
object then you have to implement the Serializable interface
otherwise the compiler will throw an error. To make more
clearly understand the concept of marker interface you
should go through one more example.

Suppose the interface Clonable is neither implemented by a
class named Myclass nor it's any super class, then a call to
the method clone() on Myclass's object will give an error.
This means, to add this functionality one should implement
the Clonable interface. While the Clonable is an empty
interface but it provides an important functionality.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we use both this () and super () in a constructor?

555


What is final keyword in java?

554


What are the differences between include directive and include action?

546


Which list is sorted in java?

583


How do you sort in ascending order in java?

521






Which language is java?

546


What is a stringbuffer?

513


What does 3 dots mean in java?

520


How can you add and remove nodes in jtree?

612


Do you know why doesn't the java library use a randomized version of quicksort?

554


What is abstract class constructor called?

570


How do I stop concurrentmodificationexception?

511


Can a static block throw exception?

654


What are disadvantages of java?

520


Why are global variables used?

503