It's not a secret anymore!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes How to Know Interface methods?(Very Imp.) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "How to Know Interface methods?(Very Imp.)" Watch "How to Know Interface methods?(Very Imp.)" New topic

How to Know Interface methods?(Very Imp.)


Joined: Oct 19, 2000
Posts: 1
I have Created my Interface and given four methods inside the Interface.I compiled my Interface and given the compiled interface file to my Friend.
How do my friend know that what are the methods inside the Interface, so that he can implement the Interface in his class?
Udayan Naik
Ranch Hand

Joined: Oct 18, 2000
Posts: 135
Well , it depends on the interface designer himself.
1)The first way is to provide some sort of documentation to the person who wants to implement that interface.The best way is to use the javadoc tool available from Sun.
2)The second way would be to implement the interface and compile the class.From the errors the compiler throws , which could be of the form "class XYZ shoulde be ddeclared abstract because it does not implement method ABC()..." your friend will come to know abot the methods u have provided in that interface.
Any other suggestions are welcome.
Come on in !! Drinks are on the house in the Big Moose Saloon !!

Udayan Naik<BR>Sun Certified Programmer for the Java 2 Platform
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
Read this post for more details.

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3635
It is the responsibility of the interface developer to publish it! What good an interface is, if the publisher doesn't tell what it is for?
Also note that, publishing an interface doesn't mean just telling the method names and parameters. You also have to tell the semantics, use and pretty much everything that helps a user to implement that interface 'resposibly'.
Best example is JDBC, all the classes are actually interfaces. They come with complete documentation of what they do. Vendors who implement those interfaces must stick to the interfaces' meaning/use.

Of course, you can run javap on the class file and find all the methods/fields.

Get Certified, Guaranteed!
(Now Revised for the new Pattern)

Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
I agree. Here's the link:
subject: How to Know Interface methods?(Very Imp.)
It's not a secret anymore!