0

As Object class is the base of every class, can we conclude JAVA is supporting multiple inheritance for a Cat class extending Animal class.

I read on explanation on page(Inheritance in java and Superclasses(Object, Class)).

But to my understanding it seems too me like below:

   Object

   ^    ^

Animal   ^ 

   ^    ^ 

    Cat
2
  • Object is parent of Animal class.Cat extends Animal class. Thus, hierarchy is as follows: Object->Animal-> Cat. Java is following a single inheritance hierarchy. Its only when its like Man extends Monkey, Ape {} that we call as multiple inheritance. Commented Nov 8, 2017 at 10:00
  • 1
    Well, not quite! Cat does not directly inherit from Object. So this is not multiple Inheritance. Commented Nov 8, 2017 at 10:01

2 Answers 2

0

If you don't specify any superclass in the extends clause, you extend from Object directly. If you specify a class in the extends clause, you extend from this class, which extends its own superclass, etc., until Object.

Sign up to request clarification or add additional context in comments.

Comments

0

Multiple inheritance refers to a class inheriting directly from two classes. Single inheritance in Java means that you can always have only ONE parent. You would have still many ancestors. Object will always be the first ancestor in the line of inheritance. In Java, you cannot inherit Cat from Animal and HashMap at the same time for example. A real life example would be a child who inherits features from mum and dad. But with Java, that's not possible.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.