Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding Marker Interface?

 
V. Potluri
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

As I know that market interface doesn't contain any methods or variables.
But JVM provides extra capability to the class that implements marker interface. For example, we can create clone of an object if it's class implements Clonable interface. Otherwise we cannot create clone of an object. Violating above rule raises runtime exception called CloneNotSupportedException.

Can we call Comparator interface as an marker interface eventhough it is having abstract method called compare. The signature of comapare in Comparator interface is as follows:



1. Can we call Comparator interface as marker interface?
2. Is any interface in java ,with methods called as marker interface?

Waiting for reply. Thanks in advance!

Have a wonderful day ahead!

Regards,
Gopal
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But JVM provides extra capability to the class that implements marker interface.

Let's be precise: some code somewhere provides the extra functionality. Often it's in the class libraries -not the JVM- (like for Serializable and Cloneable), but if you were to define a marker interface, then your code would have to implement its special functionality.

Can we call Comparator interface as marker interface?

Is any interface in java ,with methods called as marker interface?

No and no. Why would they? Marker interfaces are specifically those without methods.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic