This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

why java not providing multiple inheritance  RSS feed

 
prashant fusate
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

please anybody tell me why java does not provide mutiple inheritance


Thanks
 
Nigel Browne
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question is answered in this article
 
LJ Bell LJ Bell
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Java does allow multiple inheritance via use of Super references and implementing interfaces. See A Programmers Guide to Java Certification copyright 2000 by Khalid A. Mughal. Example 6.9 and page 198.

Looking forward to other responses to this question.
[ December 16, 2005: Message edited by: LJ Bell LJ Bell ]
 
amod gole
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi prashant,

as LJ Bell LJ Bell saya that java allow multiple inheritance using interface and super referance

there is another method with the help of which you can achive multiple inheritance

first understand inner class concept => class inside class ok

now what is multiple inheritance

class parent1 class parent2

class child1

in child1 you are able to access method from both classes p1 and p2

now see inner classes

class outside extend parent1
{
code{}

class inner extends parent2
{ code----
}
}

now using object of inner class you are able to access method from both both parent class








 
hem kumar
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think all should check the link provided by Nigel Browne. It is eshustively discussed there. thank u
 
kenji mapes
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
amod gole brought up some really good points. When I started learning about inheritnace, dynamic binding, polymorphism, it took me a while to understand the ramifications of it all.

But with single inheritance, it is only driect inheritance, but you are inheriting a "single line" if you will from multiple classes. Just like Class Object. We might create a parent but the child inherits from diectly from the parent but also from Object, which is the parent to our parent class.

Interfaces allow direct inheritance from multiple classes. Once you start using the Component class and using such things as JFrame, JPanel, etc, and notice their immensity and "tree of inheritance," and get into event driven programming you'll see how awesome inheritance is and the imortance of interfaces.
 
Madhuri Chanda
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Why Java does not support Pointers?"
"Why there is no goto statement in java?"

The answer is same.... To make it simple and avoid complex programming.

Thanks.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!