How can i invoke a method when i created a object with different class name and different constructor name
<pre><code>package override;

class Super
{
    public void dosomething()
    {
        System.out.println("hello Super");
    }
}

class sub 
    extends Super
{
    @Override
    public void dosomething()
    {
        System.out.println("hello sub");
    }
}

public class Main 
{
    public static void main(String[] args) 
    {
        Super p1=new Super();
        Super p2=new sub();  // Please explain why this line is correct as constructor and //class name should be same
        p1.dosomething();
        p2.dosomething();
    }
}
</code></pre>

<p>How can I invoke a method when I created a object with different class name and different constructor name.  Like the statement highlighted above has a different way of invoking a constructor</p>
