Results 1 to 7 of 7

Thread: marker interface....

  1. #1
    Contributing Member
    Join Date
    Sep 2006
    Answers
    962

    marker interface....

    What is marker interface ? What is the use for that one ?

    ------------------
    suresh


  2. #2
    Junior Member
    Join Date
    Dec 2006
    Answers
    5

    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.


  3. #3
    Contributing Member
    Join Date
    Sep 2006
    Answers
    962

    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


  4. #4
    Junior Member
    Join Date
    Jun 2006
    Answers
    1

    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.

  5. #5
    Junior Member
    Join Date
    Feb 2007
    Answers
    4

    Red face Re: marker interface....

    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.




  6. #6
    Junior Member
    Join Date
    Feb 2007
    Answers
    4

    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.


  7. #7
    Junior Member
    Join Date
    Feb 2007
    Answers
    10

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact