File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Java does not support multiple inheritance...? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java does not support multiple inheritance...?" Watch "Java does not support multiple inheritance...?" New topic
Author

Java does not support multiple inheritance...?

Som s
Greenhorn

Joined: Sep 24, 2008
Posts: 1
Hi Friends can anyone explain me how Java does not support multiple inheritance?

If a class inherits properties of more than one class then it is called multiple inheritance.

In Java, all classes extends Object class implicitly. Condsider a class B which extends class A. Here class B implicitly extends Object class. In this scenario class B inherit the properties of both class A as well as class Object, so this should be considered as multiple inheritance but we consider that java does not support multiple inheritance, why...?

-Som
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18765
    
  40

In Java, all classes extends Object class implicitly. Condsider a class B which extends class A. Here class B implicitly extends Object class. In this scenario class B inherit the properties of both class A as well as class Object, so this should be considered as multiple inheritance but we consider that java does not support multiple inheritance, why...?


The definition of multiple inheritance is the ability to inherit from multiple classes (from different hierachies). For example, if class B extends from class A, and class C extends from class A. Mulitple inheritance is the ability to inherit from both class B and C.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Rupert matthews
Greenhorn

Joined: Feb 26, 2008
Posts: 9

In Java, all classes extends Object class implicitly. Condsider a class B which extends class A. Here class B implicitly extends Object class. In this scenario class B inherit the properties of both class A as well as class Object, so this should be considered as multiple inheritance but we consider that java does not support multiple inheritance, why...?


I think the difference is java doesn't support mulitple inheritance "explicitly." Like in c++ a class of the following can work..

class c extends A, B
()
{}

but this doesn't work in Java. Although class C is implicitly the subclass of its superclass class A, in other scenarios of "classing", it will not work.

Interface is the counterpart of inheritance in Java so we can still use the properties of the superclass of our class program.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38519
    
  23
Probably best to say that interfaces mimic multiple inheritance, and A----->B----->C is called single inheritance.

It would only be multiple inheritance if you could draw a diagram like this
 
wood burning stoves
 
subject: Java does not support multiple inheritance...?