• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Interview Question.

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you everyone.....
 
reply
    Bookmark Topic Watch Topic
  • New Topic