Do we inherit from Object?

Do we guys inherit Object from any other class (except, of course, that we don’t need to explicitly specify this), or are there special privileges for the Object class, and it is not inherited like other classes?

+5
source share
3 answers

No, this is the same. Here is an excerpt from JLS 8.1.3 :

If the class declaration for any other class does not have an extends condition, then the class has the class Objectas its implicit direct superclass.

Of course, Objectin itself a little special ( JLS ):

, Object, (.. ) (§8.1.3) (§8.1.4).

+2

Java . , Object, , Object.

, , ( ) Object Java.

EDIT: Java " - ". - .

:

  • A , Object.

  • A B, Object, B Object.

+5

Everything is an object in Java. All Object methods ( toString(), wait()etc.) can be called on any instance of any Java class.

0
source

All Articles