What is Marker Interface

What is Marker Interface:

  • The interface without any member is called Marker Interface.
  • It is just an empty interface.
  • The uses of Marker Interface is to send the special message to JVM about the class
Example of Marker Interface:

when we want to make a clone of any class object then we need to send the instruction to JVM that class is eligible for cloning. we can do this by implementing the marker interface.

Interface



package com.javaforecast4u.file;

public interface JFCUCloneable {

}

 Class implemented this interface



package com.javaforecast4u.file;

public class Employee implements JFCUCloneable{
      
       int empId;
       Employee(int empId){
              this.empId = empId;
       }
       public Employee empClone() throws CloneNotSupportedException {
              if(this instanceof JFCUCloneable){
                     return new Employee(empId);
              }
              else{
                     throw new CloneNotSupportedException("Clone Not support ");
              }
       }
}

Test Class
 

package com.javaforecast4u.file;

public class MarakerInterfaceTest {

       public static void main(String[] args) throws CloneNotSupportedException{
             
              Employee emp = new Employee(1001);
              System.out.println("EmpId:"+emp.empId);
              Employee emp1 = new Employee(emp.empId);
              System.out.println("EmpId:"+emp1.empId);
              System.out.println(emp == emp1);
             
       }

}


OUTPUT:
EmpId:1001
EmpId:1001
false


20 comments :

  1. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Android training in chennai
    Ios training in chennai

    ReplyDelete
  2. Thank you for posting, its a nice post and very useful.
    Best Oracle Training in Bangalore

    ReplyDelete
  3. I really appreciate the information shared above. It’s of great help. If someone wants to learn Online (Virtual) instructor lead live training in #ALFRESCO, kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor-led training on #ALFRESCO. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ pieces of training in India, USA, UK, Australia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain, and UAE etc.
    Avishek Priyadarshi
    MaxMunus
    E-mail: avishek@maxmunus.com
    Skype id: avishek_2.
    Ph:(0) 8553177744 / 080 - 41103383
    http://www.maxmunus.com/

    ReplyDelete
  4. Really thanks for sharing such a great information with us.
    Also, many thanks for permitting me to comment!
    Quicken Support Number
    Quicken Online Support Number
    Quicken tech Support Number
    HP Support Number

    ReplyDelete
  5. Great work. Quite a useful post, I learned some new points here.I wish you luck as you continue to follow that passion.

    Linux Admin Training
    Linux Training in Chennai

    ReplyDelete
  6. Thanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.

    rpa training in marathahalli

    rpa training in btm

    rpa training in kalyan nagar

    rpa training in electronic city

    rpa training in chennai

    rpa training in pune

    rpa online training

    ReplyDelete
  7. This is a nice article here with some useful tips for those who are not used-to comment that frequently. Thanks for this helpful information I agree with all points you have given to us. I will follow all of them.

    Data Science training in chennai
    Data science training in velachery
    Data science training in tambaram
    Data Science training in OMR
    Data Science training in anna nagar
    Data Science training in chennai
    Data science training in Bangalore
    Data Science training in marathahalli

    ReplyDelete
  8. That was a great message in my carrier, and It's wonderful commands like mind relaxes with understand words of knowledge by information's.
    python online training
    python training in OMR
    python training in tambaram
    python training in annanagar

    ReplyDelete
  9. This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 
    Devops Training in pune
    Devops Training in Chennai
    Devops training in sholinganallur
    Devops training in velachery
    Devops training in annanagar
    Devops training in tambaram

    ReplyDelete
  10. At this time, it seems like Word Press is the preferred blogging platform available right now. (from what I’ve read) Is that what you’re using on your blog? Great post, however, I was wondering if you could write a little more on this subject?
    Best AWS Training in Marathahalli | AWS Training in Marathahalli
    Amazon Web Services Training in Anna Nagar, Chennai |Best AWS Training in Anna Nagar, Chennai

    ReplyDelete
  11. myTectra Placement Portal is a Web based portal brings Potentials Employers and myTectra Candidates on a common platform for placement assistance

    ReplyDelete
  12. Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
    Best Selenium Training in Chennai | Selenium Training Institute in Chennai | Besant Technologies


    ReplyDelete