Classes that do not inherit the Object class

Are there classes that don't inherit an object like SuperClass, or maybe out of date or out of date?

+6
source share
4 answers

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

Other than that, all ie classes

 class ClassName { //some stuff } 

All classes implicitly extend Object unless another superclass is specified.

Interfaces, on the other hand, do not extend Object, but cannot contain invokable methods, and objects cannot be created from them. When the interfaces are finally implemented, the implementation class will necessarily extend Object. (and, no, the object does not implement any interfaces)

+16
source

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. 

Thus, all objects in Java extend it directly or indirectly.

+4
source

All Java classes inherit java.lang.Object (directly - by default or through parents). If any class or method is deprecated with some release of the platform, it is always displayed in the corresponding JavaDoc.

+1
source

Are there classes that don't inherit an object like SuperClass

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

or perhaps out of date or out of date?

A lot of them. See Javadoc.

0
source

Source: https://habr.com/ru/post/926722/


All Articles