
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
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 Articles
- Why multiple inheritance is not supported by Java?
- Why is operator overloading not supported by java?
- Java and multiple inheritance
- Multiple inheritance by Interface in Java
- Does Java support multiple inheritance? Why? How can we resolve this?
- How multiple inheritance is implemented using interfaces in Java?
- Java Program to Implement Multiple Inheritance
- What is diamond problem in case of multiple inheritance in java?
- Multiple Inheritance in C++
- Multiple inheritance in JavaScript
- C# and Multiple Inheritance
- Does Python support multiple inheritance?
- Inheritance in Java
- Haskell Program to Implement multiple inheritance
- Multilevel inheritance in Java

Advertisements