The Artima Developer Community
Sponsored Link

Java Answers Forum
Null Interface

3 replies on 1 page. Most recent reply: Sep 30, 2004 7:03 AM by Samrat Bhatnagar

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Gaurav

Posts: 1
Nickname: gaurav123
Registered: Sep, 2004

Null Interface Posted: Sep 21, 2004 10:29 PM
Reply to this message Reply
Advertisement
What is null interface??? Why do we ned null interfaces???


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Null Interface Posted: Sep 28, 2004 3:57 PM
Reply to this message Reply
> What is null interface??? Why do we ned null interfaces???

I'm a little confused here. An interface simply
lists behaviour. How would there be a Null interface...
A Null Object would be a place in Memory with nothing
or that hasn't been declared or something to that
effect. However, if all that is happening in an
interface is declaration of Method signatures
to specify behaviour how would there be a Null
Interface and what would be their purpose if there
was one?

Just trying to learn like y'all guys. What
web site or book did you see this at?

Spike

Sandu Crasteti

Posts: 13
Nickname: xan
Registered: Feb, 2003

Re: Null Interface Posted: Sep 29, 2004 2:58 AM
Reply to this message Reply
Hi!

I quote the Java Tutorial:

"Empty interfaces can be used as types and to mark classes without requiring any particular method implementations. For an example of a useful empty interface, see java.io.Serializable."

Have a nice day!

Samrat Bhatnagar

Posts: 2
Nickname: ironman166
Registered: Sep, 2004

Re: Null Interface Posted: Sep 30, 2004 7:03 AM
Reply to this message Reply
I thought i should elaborate this topic.

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.

Flat View: This topic has 3 replies on 1 page
Topic: How one applet can see database?( the applet and databaseis on a webserver) Previous Topic   Next Topic Topic: Help me to make a Link List method

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use