Why there are some null interface in java. What does it mean. Give me some null interfaces in JAVA

Showing Answers 1 - 9 of 9 Answers

reddybajjuri

  • Mar 26th, 2007
 

Null Interfaces also know as Marker Interfaces are simply marking the class that implements them.Now when the JVM looks at such a class it allows it to call certain methods.

e.g There is a method clone() in Object class.All classes implicitly inherit this class.So we should be able to call this method when we declare a user defined class.Try doing this and the JVM will give an error.

For this the solution is that if we implement the Clonable marker interface then JVM knows that this class can call the clone() method.So now we can call clone on this class's object.

  Was this answer useful?  Yes

Null Interfaces also know as Marker Interfaces are simply marking the class that implements them.Now when the JVM looks at such a class it allows it to call certain methods.

e.g There is a method clone() in Object class.All classes implicitly inherit this class.So we should be able to call this method when we declare a user defined class.Try doing this and the JVM will give an error.

For this the solution is that if we implement the Clonable marker interface then JVM knows that this class can call the clone() method.So now we can call clone on this class's object.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions