Java allowing multiple inheritance

JavaQuest

I am confused regarding a concept in multiple inheritance. I have three classes A, B and C.

Class A {
    // ...
}

Class B extends A {
    // ...
}

Class C extends B {
    // ...
}

I know this is a bad practice of multiple inheritance and I also read java allows multiple inheritance through interfaces. But I am not getting any error in the above code. Please can anyone explain me with a clear example without using interface. Thanks!!

Eran

This is not multi-inheritance. Each class has exactly one direct super class. If your example was considered multi-inheritance, you wouldn't be able to use the extends keyword at all, since each class already extends by default the Object class.

Multi-inheritence would be

class C extends A,B {}

And that's illegal in Java.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Multiple inheritance workaround in Java?

From Java

Java Multiple Inheritance

From Dev

Multiple inheritance and Java

From Dev

Usage of multiple inheritance in Java 8

From Dev

Java Object class and multiple inheritance

From Dev

How to avoid multiple inheritance in java

From Dev

How to explain multiple inheritance in Java

From Dev

Inheritance in Java regarding multiple classes

From Dev

Why is java allowing this to compile and what is it interpreting multiple + signs as in this case?

From Dev

Allowing sessions on multiple sites

From Dev

Java inheritance checking values for multiple variables

From Dev

Java multiple inheritance duplicate variable declaration?

From Dev

Is this a new way to implement Decorator or Multiple inheritance in Java?

From Dev

Multiple Inheritance in Java allowed with Object class?

From Dev

Porting Multiple Inheritance C++ Code to Java

From Dev

Multiple inheritance and method overriding issue in java

From Dev

Does Java 8 support multiple inheritance?

From Dev

Does Java 8 support multiple inheritance?

From Dev

Is this a new way to implement Decorator or Multiple inheritance in Java?

From Dev

MongoEngine: Documents disappear after allowing_inheritance

From Dev

Allowing Wordpress Users Multiple Logins

From Dev

Allowing multiple models to access a controller

From Dev

allowing multiple inputs to python subprocess

From Dev

Datepicker and allowing multiple input formats

From Dev

Allowing Wordpress Users Multiple Logins

From Dev

Allowing multiple models to access a controller

From Dev

about Multiple inheritance and virtual inheritance

From Dev

multiple inheritance without virtual inheritance

From Dev

Multiple inheritance or Multiple interfaces

Related Related

  1. 1

    Multiple inheritance workaround in Java?

  2. 2

    Java Multiple Inheritance

  3. 3

    Multiple inheritance and Java

  4. 4

    Usage of multiple inheritance in Java 8

  5. 5

    Java Object class and multiple inheritance

  6. 6

    How to avoid multiple inheritance in java

  7. 7

    How to explain multiple inheritance in Java

  8. 8

    Inheritance in Java regarding multiple classes

  9. 9

    Why is java allowing this to compile and what is it interpreting multiple + signs as in this case?

  10. 10

    Allowing sessions on multiple sites

  11. 11

    Java inheritance checking values for multiple variables

  12. 12

    Java multiple inheritance duplicate variable declaration?

  13. 13

    Is this a new way to implement Decorator or Multiple inheritance in Java?

  14. 14

    Multiple Inheritance in Java allowed with Object class?

  15. 15

    Porting Multiple Inheritance C++ Code to Java

  16. 16

    Multiple inheritance and method overriding issue in java

  17. 17

    Does Java 8 support multiple inheritance?

  18. 18

    Does Java 8 support multiple inheritance?

  19. 19

    Is this a new way to implement Decorator or Multiple inheritance in Java?

  20. 20

    MongoEngine: Documents disappear after allowing_inheritance

  21. 21

    Allowing Wordpress Users Multiple Logins

  22. 22

    Allowing multiple models to access a controller

  23. 23

    allowing multiple inputs to python subprocess

  24. 24

    Datepicker and allowing multiple input formats

  25. 25

    Allowing Wordpress Users Multiple Logins

  26. 26

    Allowing multiple models to access a controller

  27. 27

    about Multiple inheritance and virtual inheritance

  28. 28

    multiple inheritance without virtual inheritance

  29. 29

    Multiple inheritance or Multiple interfaces

HotTag

Archive