+ 2
Why multiple Inheritance does not support in java
can anybody ans me
10 Antworten
+ 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..
+ 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();
}
}
+ 3
you can achieve multiple inheritance by implementing multiple interface in a class.
+ 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/
+ 2
https://docs.oracle.com/javase/tutorial/java/IandI/multipleinheritance.html
+ 1
i got your point
what if..
we change the name of methods..
+ 1
can you provide me..
more other reason of this
+ 1
can anyone provide me more reason behind this
+ 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
0
because it support ambiguity