Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Classes that don't inherit Object class

Tags:

java

object

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

like image 399
Arham Avatar asked Oct 02 '12 03:10

Arham


Video Answer


2 Answers

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).

like image 150
Ryan Amos Avatar answered Sep 20 '22 05:09

Ryan Amos


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.

like image 22
tanyehzheng Avatar answered Sep 21 '22 05:09

tanyehzheng