File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "interface" Watch "interface" New topic
Author

interface

Bharat Kothari
Greenhorn

Joined: Sep 09, 2007
Posts: 1
what is purpose of using interfaces rather than allowing multiple inheritance of classes as in C++??
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30352
    
150

Bharat,
Welcome to JavaRanch!

In C++, you can have two superclasses each containing a method with the same signature. When this happens, how does the subclass know which implementation to inherit? Java gets rid of this sticky situation by only allowing you to extend the implementation of one superclass hierarchy. You can use an interface for any other signatures/contracts you need. Since you supply the implementation, there are no conflicts in this case.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: interface