Classes that don't inherit Object class

前端 未结 4 1147
星月不相逢
星月不相逢 2020-12-03 12:27

Are there any classes that don\'t inherit Object as SuperClass or maybe have become Obsolete/deprecated?

相关标签:
4条回答
  • 2020-12-03 12:46

    According to Java Object superclass, java.lang.Object does not extend Object.

    Other than that, all classes, i.e.

    class ClassName {
        //some stuff
    }
    

    implicitly extend Object class, if they don't extend any other super-class.

    Interfaces, on the other hand, do not extend Object, as Interface, by definition, can not extend Class. Also, Interfaces can not contain callable methods, nor can objects be instantiated from them. When interfaces are finally implemented, the implementing class will necessarily extend Object (and, no, Object doesn't implement or extend any other entity/class/interface).

    0 讨论(0)
  • 2020-12-03 12:48

    All Java classes inherit java.lang.Object (directly - by default, or via parents). If some class or method become deprecated with some platform release, it is always reflected in appropriate JavaDoc.

    0 讨论(0)
  • 2020-12-03 13:00

    According to java.lang.Object javadoc

    Class Object is the root of the class hierarchy. Every class has Object as a superclass. All objects, including arrays, implement the methods of this class.

    So, all objects in Java extends it directly or indirectly.

    0 讨论(0)
  • 2020-12-03 13:00

    Are there any classes that don't inherit Object as SuperClass

    There is exactly one of those, and it is java.lang.Object itself. Also all interfaces.

    or maybe have become Obsolete/deprecated?

    There are plenty of those. See the Javadoc.

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