Geeks Talk

Prepare for your Next Interview




marker interface....

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...


Go Back   Geeks Talk > Software Development > Java

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 12-29-2006
Contributing Member
 
Join Date: Sep 2006
Location: bangalore, india
Posts: 1,007
Thanks: 0
Thanked 76 Times in 64 Posts
psuresh1982 will become famous soon enough
marker interface....

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

------------------
suresh
Reply With Quote
The Following User Says Thank You to psuresh1982 For This Useful Post:
Sponsored Links
  #2 (permalink)  
Old 12-29-2006
Junior Member
 
Join Date: Dec 2006
Location: Chennai India
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
srinivasanraju is on a distinguished road
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.
Reply With Quote
  #3 (permalink)  
Old 12-30-2006
Contributing Member
 
Join Date: Sep 2006
Location: bangalore, india
Posts: 1,007
Thanks: 0
Thanked 76 Times in 64 Posts
psuresh1982 will become famous soon enough
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
Reply With Quote
  #4 (permalink)  
Old 01-31-2007
Junior Member
 
Join Date: Jun 2006
Location: India
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
chg81713 is on a distinguished road
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.
Reply With Quote
  #5 (permalink)  
Old 02-19-2007
Junior Member
 
Join Date: Feb 2007
Location: coimbatore, chennai
Posts: 8
Thanks: 4
Thanked 0 Times in 0 Posts
jananianandan is on a distinguished road
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.

Reply With Quote
  #6 (permalink)  
Old 02-19-2007
Junior Member
 
Join Date: Feb 2007
Location: coimbatore, chennai
Posts: 8
Thanks: 4
Thanked 0 Times in 0 Posts
jananianandan is on a distinguished road
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.
Reply With Quote
  #7 (permalink)  
Old 02-21-2007
Junior Member
 
Join Date: Feb 2007
Location: Banglore
Posts: 10
Thanks: 0
Thanked 1 Time in 1 Post
vardhan59 is on a distinguished road
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.
Reply With Quote
Reply

  Geeks Talk > Software Development > Java


Thread Tools
Display Modes


Similar Threads

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


All times are GMT -4. The time now is 12:59 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved