| |
GeekInterview.com > Interview Questions > J2EE > Core Java
| Print | |
Question: Marker Interface
Answer: When there is no methods in the marker interface, then what is the use of marker interface. What is the functionality of the interface. Why do we need to implement marker interface? |
| October 10, 2009 06:53:38 |
#4 |
| ae8166558de88 |
Member Since: October 2009 Total Comments: 3 |
RE: Marker Interface |
If a class implements any interface than the object of that class is also interface type, i.e. object instanceof interface is true. And when an Object is required to be treated in some specific functionality say cloning or serialization the object is first checked that the object is eligible to be used for that type of functionality. If no special method is required in object the interface is kept with no method and is called Marker interface. e.g. in ObjectOutputStream object is checked with if (obj instanceof Serializable)
these are my views only don't know what actual intention java creaters had... |
| |
Back To Question | |