title: What exactly happens during object creation? (Java)
body: <p>I've been studying from <em>Head First Java</em> and I'm currently on the constructors chapter. They've explained that an object is created by calling a constructor after the <code>new</code> keyword. </p>
  
  <p>My question: What is it exactly that runs when you create a new object? <br> <br> Let's take the following as sample code:</p>
  
  <pre><code>public class Const {
  
      // instance variables
      int number;
      String name;
  
  
      // Constructors
      public Const() {
          //implicit super
          System.out.println("no-arg constructor");
      }
      public Const(int i, String s) {
          //implicit super()
          number = i;
          name = s;
          System.out.println("two-arg constructor");
      }
  
  
      // test method
      public void doSomething() {
          System.out.println("I'm a test");
      }
  
  
      // Main
      public static void main(String[] args) {
  
          Const c1 = new Const();
          Const c2 = new Const(5, "Jerry");
      }
  }
  </code></pre>
  
  <p>Now here is what I believe is happening under the hood when creating <code>c1</code>:<br></p>
  
  <ol>
  <li><code>public Const()</code> is called</li>
  <li><code>super()</code> is called</li>
  <li>the <code>Object</code> part of Const is built.</li>
  <li><code>public Const()</code> is back on top of the stack.</li>
  <li>Now here comes my trouble. When and how exactly are the instance variables and methods for the object created (what implicit code is added)?</li>
  </ol>