Basic computer course, C programming language, Education, Engineering Course, Engineering Courses, Maths Coaching, online computer coaching, PGDCA course coaching, programming course, school computer coaching, training, Uncategorized, Web Design course

Why does java not support multiple inheritances? tccicomputercoaching.com

Java doesn’t support multiple inheritances for classes but it supports multi-level inheritance for classes and multiple inheritances in interfaces.

Let us we understand in detail why does java not support multiple inheritance?

java support not multiple inheritance

class A

{

void show()

{

}

}

class B

{

void show()

{

}

}

class C extends A,B

{

public static void main(String args[])

{

C obj=new C();

obj.show()

}

}

In the above example compiler will never know which method to invoke. Because show() method is there in both classes and both classes have different implementation for show() method.

But in interface implementation is unique if interfaces have the same method…

i.e. interface I1

{

show();

}

interface I2

{

show();

}

class A implements I1,I2

{

void show()

{

……………..

………………

}
public static void main(String args[])

{

A obj=new A();

obj.show()

}

}

Here, only declaration of method given in interface but implementation given only in class. So, only method from implementing class is going to be executed.

TCCI teach all programming Language concepts in Bopal and Satellite in Ahmedabad.

To learn more about Programming at TCCI.

Call us @ 9825618292

Visit us @ http://www.tccicomputercoaching.com

 

Leave a comment