Is it possible in Java to implement something similar to Object.clone()?
<p>The Object.clone() method in Java is pretty special, as instead of returning a copy of the object that is to be cloned with the Object type, it returns the correct Object type. This can be better described with the following code:</p>

<pre><code>class A implements Cloneable
{
    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

class B extends A {
}

public class MainABC {
    public static void main(String[] args) throws CloneNotSupportedException {
        B b = new B();
        B b1 = (B)b.clone(); //see here that we are using A's .clone(). The only
                             //thing it does is call Object's clone().
        System.out.println(b1.getClass()); //but as we see here, its not an Object
                                           //its a B!
    }
}
</code></pre>

<p>So, could anyone explain if possible if is there anyway to replicate what happens inside Object.clone()'s method?</p>
