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

Is string a wrapper class?

505


What are meta-annotations?

545


What is a boolean in java?

569


How do you sort arrays in java?

516


What is the size of boolean variable?

566






How do you detect memory leaks?

574


What is ternary operator?

557


Explain the importance of join() method in thread class?

632


What is the use of http-tunneling in rmi?

539


Are static members inherited to sub classes?

629


Difference between current previous versions of Java?

549


What is meant by object?

568


What is the maximum size of arraylist in java?

484


Whats the difference between notify() and notifyall()?

560


What is an interoperable application in java ?

576