Why multiple Inheritance does not support in java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why multiple Inheritance does not support in java

can anybody ans me

29th Mar 2018, 7:59 PM
Arun Tomar
Arun Tomar - avatar
10 Answers
+ 1
today i got the second reason of this answere.. I want to share with you all.. class A. class B { { A(); B(); } } class C extends A,B { C(); } let suppose.. if java give permission to support multiple inheritance.. now tell me which constructor should run first... because there is a rule in java.. if a child class constructor run before executive itself. it must run the parent class constructor.. i.e The second reason.. java dont not support multiple inheritance... pls let me know.. if i'm wrong some where.. and i hope you like it..
23rd Apr 2018, 7:08 PM
Arun Tomar
Arun Tomar - avatar
+ 7
If the parent classes methods have same name and you call the method from the child class it doesn't know which method to call class first { void call() { } } class second{ void call() { } } class main extends first, second { public static void main(String args[]) { main ob = new main(); ob.call() //compiler error. We have 2 methods called call(); } }
29th Mar 2018, 8:09 PM
Toni Isotalo
Toni Isotalo - avatar
+ 3
you can achieve multiple inheritance by implementing multiple interface in a class.
29th Mar 2018, 11:08 PM
Heji Palaña
Heji Palaña - avatar
+ 2
Java was created with an aim to develop a language similar to C++ without carrying over it's complexities and shortcomings. Java was designed to be a simple language. The concept of multiple inheritance usually leads to ambiguities and hence errors. Therefore to avoid this ambiguity and for less complexity, the developers made Java not support multiple inheritance. Read here:- http://crbtech.in/Java-Training/java-doesnt-support-multiple-inheritance/
2nd Apr 2018, 5:05 AM
pranit patil
pranit patil - avatar
+ 2
https://docs.oracle.com/javase/tutorial/java/IandI/multipleinheritance.html
24th Apr 2018, 8:20 PM
Aleksandr Efremov
Aleksandr Efremov - avatar
+ 1
i got your point what if.. we change the name of methods..
29th Mar 2018, 8:13 PM
Arun Tomar
Arun Tomar - avatar
+ 1
can you provide me.. more other reason of this
30th Mar 2018, 3:37 AM
Arun Tomar
Arun Tomar - avatar
+ 1
can anyone provide me more reason behind this
1st Apr 2018, 3:58 PM
Arun Tomar
Arun Tomar - avatar
+ 1
pls answere this post I got it thanks every one.. for helping me.. Actually I was given the interview at tcs. I explain all of these.. but they asked me.. 2 reason...?? 1.reason i say. overriding the same method of two different class cause the ambiguity... 2.reason i still dont know pls if anyone know this... ans me
2nd Apr 2018, 5:30 AM
Arun Tomar
Arun Tomar - avatar
0
because it support ambiguity
8th Jun 2018, 5:57 PM
Nilamani