aspose file tools*
The moose likes Beginning Java and the fly likes Interview Question. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Interview Question." Watch "Interview Question." New topic
Author

Interview Question.

Shivit Agarwal
Ranch Hand

Joined: Feb 28, 2008
Posts: 82
Hello,
What should we reply to the question.
"Is Multiple Inheritence possible in Java? "

The answer is ovious No. But via interface we achieve this indirectly.


Have the determination of mirror which never fails to reflect in spite of being broken into pieces.<br /> <br />Kiss the hands you cannot bite.<br /> <br />An Optimist is one who starts taking a bath when he accidentally falls into the water.
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1280

Hi Shivit,

technically there is definitely no possibility of multiple inheritance in Java, as you said. Also you're right that you can achieve something similar with implementation of multiple interfaces.
Other languages are in fact using a kind of multiple inheritance for this purpose. There you don't really inherit in the sense of an is-a relationship but inherit from one or more mixin classes. These mixin classes simply add some part of functionality to your actual class like interfaces do in Java. So from that perspective you could say Java in a way uses its own kind of "multiple inheritance" without exposing the risks of using real multiple inheritance incorrectly in languages like C++.

Marco
Gavin Tranter
Ranch Hand

Joined: Jan 01, 2007
Posts: 333
I have to say, I never agree with the idea that interfaces provide a mesaure of multiply inheritance, I just think it complicates matters to think that way.

It is worth noting that Java does indeed support multiply inheritance, of interfaces!

My answer to that question would be:
"Are we talking multiply inheritance of Classes or Interfaces?"

Gavin
Shivit Agarwal
Ranch Hand

Joined: Feb 28, 2008
Posts: 82
Thank you everyone.....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Interview Question.