Marker interface means , interface which has no methods.Then
what is the necessity of its usage.I read "it tells the
compiler that it should be treated differently ". "It is
used to store state of an object". But still am not
clear.Please explain clearly.

Answer Posted / pratap jadaun

Marker interface means, interface which has no methods. Then
what is the necessity of its usage. I read "it tells the
compiler that it should be treated differently ".

but the marker interface is not only
used to store state of an object

below given list of marker interfaces

- java,lang.Cloneable
- java,io.Serializable
-java.util.EventListener
....

these are marker interfaces in java and each interface is
used for different purpose

A class implements the Cloneable interface to indicate to
the Object.clone() method that it is legal for that method
to make a field-for-field copy of instances of that class.


"Serializable is used to store state of an object".

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we call thread start () twice?

521


What is the char data type?

531


Explain working of call by reference function invoking.

594


What does string [] args mean?

543


What are the supported platforms by java programming language?

573






How to make a write-only class in java?

579


Which collection does not allow duplicates in java?

478


How to convert string to char and vice versa?

520


What is the difference between @before and @beforeclass annotation?

546


How can we make a class singleton?

582


Where is const variable stored?

538


How does arraylist size increase in java?

533


Can a static method be overridden in java?

559


Does hashset allow duplicates in java?

586


Explain throw keyword in java?

618