Java: does Object class have a constructor?

constructor, java

Solution

Super constructors are run before sub/base constructors. In your example Object's constructor has already been run when `new Throwable().printStackTrace()` is executed.

A more explicit version of your code:

public ConTest()
{
    super();
    new Throwable().printStackTrace(); // you will not see super() (Object.<init>) in this stack trace.
}

Problem

Javadoc mentions that Object class has a public no-arg constructor. But Object's source code doesn't have any explicit constructor in it. So obviously the compiler has generated one for it. However, if I see the call stack trace when a constructor is about to return (as shown below), I do not see any call to `Object.<init>` in that trace. So the question is, does Object class have a default constructor as the doc says? If yes, why do I not see it in the call stack trace? ``` public ConTest() { new Throwable().printStackTrace(); } ``` Result: ``` java.lang.Throwable at ConTest.<init>(ConTest.java:8) at ConTest.main(ConTest.java:16) ```

Original source