Inheritance in java and Superclasses(Object, Class)

前端 未结 7 1593
太阳男子
太阳男子 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:07

    Object is the superclass of every other class. When your Child class inherits from your Parent class, it is not the child of Object, but it is still a descendant, because its parent is a descendant of Object. So if you don't specify a superclass/parent, it will automatically be Object. If you do specify a parent, then Object will still be a superclass, because it is by definition a superclass of the parent class.

    Class is not a superclass of each class, but the Object class specifies a means to get each class's Class with the getClass method.

提交回复
热议问题