public class Test
{
  public static void main(String args[])
  {
    A a = new B(); // object of type B
  }
}
Here the object is of type Class B but is referred by a variable of type Class A
Doing A a = new A() and A a = new B() both only allow me to access members and methods of Class A then why should I instantiate variable a with constructor of Class B ?
How is this exactly represented in Memory and what exactly happens ?
 
    