

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Why multiple inheritance is not supported in Java
In Java, a class cannot extend more than one class. Therefore following is illegal −
Example
public class extends Animal, Mammal{}
However, a class can implement one or more interfaces, which has helped Java get rid of the impossibility of multiple inheritances.
The reason behind this is to prevent ambiguity.
Consider a case where class B extends class A and Class C and both class A and C have the same method display().
Now java compiler cannot decide, which display method it should inherit. To prevent such situation, multiple inheritances is not allowed in java.
- Related Questions & Answers
- Why multiple inheritance is not supported by Java?
- Why is operator overloading not supported by java?
- Java and multiple inheritance
- Does Java support multiple inheritance? Why? How can we resolve this?
- How multiple inheritance is implemented using interfaces in Java?
- Multiple inheritance by Interface in Java
- Java Program to Implement Multiple Inheritance
- Multiple Inheritance in C++
- Multiple inheritance in JavaScript
- What is diamond problem in case of multiple inheritance in java?
- C# and Multiple Inheritance
- Does Python support multiple inheritance?
- Why the transient variable is not serialized in Java?
- Inheritance in Java
- Difference Between Single and Multiple Inheritance
Advertisements