Inheritance in java and Superclasses(Object, Class)

前端 未结 7 1448
太阳男子
太阳男子 2020-11-30 11:47

Is java.lang.Object superclass of all the custom class/objects inherited implicitly? I thought java didn\'t support multiple inheritance. The reason I ask is i

相关标签:
7条回答
  • 2020-11-30 12:21

    The custom class that you inherit from itself inherits directly or implicitly from Object, so you indirectly inherit from Object. The chain goes YourObject -> MiddleObject -> java.lang.Object. No multiple inheritance necessary.

    Multiple inheritance is when you directly inherit from two unrelated classes. For example, if you have a class PoliceDog that inherits directly from both Canine and PoliceOfficer, that would be multiple inheritence.

    0 讨论(0)
提交回复
热议问题