ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

Is multiple inheritance possible in java? If yes then how? If no then why?

user-image
تم إضافة السؤال من قبل himanshu mittal
تاريخ النشر: 2013/07/04
مستخدم محذوف‎
من قبل مستخدم محذوف‎

multiple inheritance can be achived using multiple interface implementaion in java

مستخدم محذوف‎
من قبل مستخدم محذوف‎

No.
Multiple inheritance is not possible in Java.
Implementing multiple interfaces is not inheritance at all.
In inheritance,we get the functionalities whereas by implementing multiple interfaces,we provide the functionalities.

Javed Khan
من قبل Javed Khan , Senior Programmer Analyst , Barclays Technology

Java does support Multiple interface inheritance.
Which means behavior can be inherited from multiple interfaces but one has to provide implementation of that behavior.

In java Multiple Inheritance is not possible.It can be posiible by implementing an interfaces

Ashish Gupta
من قبل Ashish Gupta

Multiple inheritance is not possible in java..in multiple inheritance we inherit all the method,member of method and class member of two or more class bt using interface it is not necessary that we achieve multiple interface each and every time.following example demonstrate it as...
interface a { void a(); void b(); } interface b { void c(); void d(); } abstract class InterfaceMultipleInheritence implements a,b { public static void main(String arr[]) { } } explanation ...we can execute it without getting member of a(),b(),c(),d()....

Omer Cheema
من قبل Omer Cheema

No.
There is no support for multiple inheritance in java.
Reason: C++ allows multiple inheritance whereas java completely rejects it.You should look into the Diamond Problem this will help you in understanding the concept.
Diamond Problem: Suppose we have two classes B and C inheriting from A.
Assume that B and C are overriding an inherited method and they provide their own implementation.
Now D inherits from both B and C doing multiple inheritance.
D should inherit that overridden method, which overridden method will be used? Will it be from B or C? Here we have an ambiguity.
Alternate:Multiple Interface Because interfaces specify only what the class is doing, not how it is doing it.
The problem with multiple inheritance is that two classes may define different ways of doing the same thing, and the subclass can't choose which one to pick.

المزيد من الأسئلة المماثلة