hi to all,
i knew something about marker interface i.e marker interface do not have the methods to override, but my friend said we can define our own methods. Which is the correct one my friends or me?
Please help me for this..
Thanks in advance.
Marker interfaces by definition need to be empty. Else they are just like any other interface. Of course this does not mean you cannot define your own method signatures in the interface. Only that, then it wont be technically a marker interface.
More information can be found in this FAQ article http://www.coderanch.com/how-to/java/Java-FAQ#marker
Nagacharan Lokkidi wrote:
but my friend said we can define our own methods. Which is the correct one my friends or me?
We can define, but again as maneesh said we cant call that as Marker interface!
Note:marker interface contains java.lang.Object's public methods implicitly, unless you declare explicitly!
If an interface has no direct superinterfaces, then the interface implicitly declares a public abstract member method mm with signature ss, return type rr, and throws clause tt corresponding to each public instance method mm with signature ss, return type rr, and throws clause tt declared in Object, unless a method with the same signature, same return type, and a compatible throws clause is explicitly declared by the interface.
Please avail yourself of the search facility of this site to find the many, many, threads where this subject has been asked and exhaustively answered before. There's no really no point in rehashing all that over and over and over again.
i am looking for marker interface details.actually i know it has no methods eg serializable,cloneable and single thread model.recently i faced a interview question ie if serializable is a marker interface means then why it has two methods writeExternal and readExternal.what is the use of marker interface,simple explanation will be helpful to me.iam so confused