How does marker interface provides functionality to the
implemented class ?

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

Answer Posted / laxman

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 ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is number data type in java?

544


What is a static class in java?

546


Is there is any difference between a scrollbar and a scrollpane?

550


Is a boolean 1 bit?

604


What do you mean by flow of struts?

734






Can we define private and protected modifiers for variables in interfaces?

569


What value is a variable of the string type automatically initialized?

601


How many decimal places is a double?

524


What is the use of conditional statement?

554


Tell me the Importent classes in net package?

1572


What is java objectoutputstream?

531


What are exception handling keywords in java?

599


What is the purpose of the enableevents() method?

569


Write a java program to check if a number is prime or not?

528


What is an object's lock and which object's have locks in java programming?

555