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
Is it possible to use Semaphore/ Mutex in an Interrupt Handler?
What is method in java with example?
Define packages in java?
When will we use them?
How do you make an arraylist empty in java?
What is anagram of a string?
What are the new features in java 8? Explain
Explain java thread life cycle.
Explain the overview of UDP messaging.
Why does it take so much time to access an applet having swing components the first time?
Why is stringbuffer called mutable?
how to one war file class to another war file class?
What is Java Annotations?
What are the different data types in java?
What is a conditional equation?