Prepare for your Next Interview
This is a discussion on marker interface.... within the Java forums, part of the Software Development category; What is marker interface ? What is the use for that one ? ------------------ suresh...
|
|||
|
marker interface....
What is marker interface ? What is the use for that one ?
------------------ suresh |
| The Following User Says Thank You to psuresh1982 For This Useful Post: | ||
| Sponsored Links |
|
|||
|
Re: marker interface....
An empty interface is known as a "marker" interface in Java. A class implementing this has a certain feature/property about it. E.g Serializable interface. Any class implementing this is serializable. Same with Cloneable interface.
Interface containing methods is normal Java interface and these methods must be implemented by any class which wishes to implement that interface. Hope this helps. |
|
|||
|
Re: marker interface....
What is the use of empty interface ? From your answer, i think the use for this to identify the class contains serializable or Cloneable etc...
But this is the only use then why they create interface ? They can easily design a java reserved keyword and then implement it... Why they particularly design a interface to acheice this goal ? ------------------- suresh |
|
|||
|
Re: marker interface....
Java interface which doesn't actually define any fields. It is just used to "mark" Java classes which support a certain capability -- the class marks itself as implementing the interface. For example, the java.lang.Cloneable interface.
To let the system know that some action can be formed on a class that implements the marker? Serializable --> Class be serialized using serialize() Cloneable --> Class can be cloned using clone() Last edited by chg81713 : 01-31-2007 at 03:31 AM. |
|
|||
|
Marker is an interface without methods examples serializable, cloneable etc.
The use of marker interface is that to indicated the compile that it has to treat the objects implementing marker interface as per the specifications of the marker interface. Example serializable interface is used to store persistent data. ![]() |
|
|||
|
Re: marker interface....
marker doesnt have methods but they accomplish the task if a class implements the marker interface,Any interface without a method acts like a marker. They just tell the compiler that the objects of the class implementing the marker interface has to be treated differently. Example Its used in the process of serialization. To send an object over network or if the state of the object has to be persisted to a flat file or a database. Deep cloning can be achieved through serialization. This may be fast to code but will have performance.
|
|
|||
|
Re: marker interface....
Hi suresh,
Technically any java object that implements java.rmi.remoteinterface this interface is a marker interface or tag interface, you know which doesn't contain any methods.A marker interface is usually used to indicate a specially features related to our class to the JVM. regards, vardhan. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| COM interface | JobHelper | QTP | 1 | 03-30-2007 02:07 PM |
| Customising XP Interface Options | Lokesh M | Windows | 3 | 02-26-2007 08:37 AM |
| Interaction between C and VB User Interface. | satya999 | C and C++ | 0 | 07-27-2006 05:31 AM |
| Extended Terminal Interface | scott | Unix/Linux | 0 | 07-17-2006 05:15 PM |
| Question with Interface | sripri | ASP.NET | 0 | 07-16-2006 12:37 PM |