If one class is derived from another that is derived from Object, is that “multiple inheritence”

前端 未结 7 1508
没有蜡笔的小新
没有蜡笔的小新 2021-01-29 09:56

The fact about Java is that it does not support the multiple inheritance.

But I have a question that the base class of all java classes is Object.

Now we have tw

7条回答
  •  无人及你
    2021-01-29 10:16

    Think of inheritance as an "is a" relation.

    In Java we can have

    A dog is a mammal is an animal

    but not

    A dog is a mamal and a four legged animal

    mammal and four leggeld animal are at the same level but mammal and animal are at different levels.

    The reason we can have the first but not the second is if we know that mammals talk in a certain way, animals talk in a certain way and four legged animals talk in a certain way we can work out the way dogs talk unambiguously in the first case but not the second.

提交回复
热议问题