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.

Answers were Sorted based on User's Feedback



Marker interface means , interface which has no methods.Then what is the necessity of its usage.I r..

Answer / 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

Marker interface means , interface which has no methods.Then what is the necessity of its usage.I r..

Answer / ras

To store the state of object

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Write a program to check for a prime number in java?

0 Answers   Cyient,


Write a program to print fibonacci series up to count 10.

0 Answers  


What is the importance of hashcode() and equals() methods?

0 Answers  


How do you format in java?

0 Answers  


what is meant by package in java?

5 Answers  






Why are lists ordered in java?

0 Answers  


Assume a thread has lock on it, calling sleep() method on that thread will release the lock?

0 Answers  


Difference between a class and an object?

0 Answers  


Class A extends Class B but Class A also inherit Super Class Object so it is multiple inheritence give reason in support of your answer

3 Answers  


What type of variable is error flag?

0 Answers  


Define how objects are stored in java?

0 Answers  


Explain the overview of UDP messaging.

0 Answers  


Categories