Using this and super() in java : <p>I am wanting to know what <code>this</code> and <code>super</code> do in the following code. I know that <code>this</code> refers to the current object and <code>super</code> is used to invoke overridden methods as well invoke a superclasses constructor. But I just can't figure out what the following code does when class <code>C</code> is executed.</p>

<pre><code>public class A {
    public A(int id) {
        super();
        this.id = id;
        System.out.println("A created");
    }
    private int id = 0;
    @Override protected void finalize() throws Throwable {
        System.out.println("A finalised");
        super.finalize();
    }
 }

 public class B extends A {
    public B(int id) {
        super(id);
        System.out.println("B created");
    }

 public B() {
    this(42);
    System.out.println("B created with default id 42");
 }
 @Override protected void finalize() throws Throwable {
    System.out.println("B finalised");
    super.finalize();
 }
}

 public class C {
    public static void main(String[] args) throws Exception{
        new B();
        System.gc();
        Thread.sleep(1000);
 }
 }
</code></pre>

<p>I am referring mainly to <code>this(42)</code>, <code>super(id)</code> and <code>super.finalize()</code>in class <code>B</code></p>

<p>-Does <code>this(42)</code> mean that <code>B</code> is instantiated with the value 42, as well as setting <code>A</code> id to 42?</p>

<p>-Does <code>super(id)</code> pass whatever value that <code>B</code> is instantiated with to its superclass which is <code>A</code> ? effectively setting the value of <code>id</code> in <code>A</code> to 42?</p>

<p>-Does <code>super.finalize()</code> call the garbage collector on to superclass <code>A</code> ?</p>
