If you do A a = new A(); then you are just creating object for Class A.
However you can do A a = new B(); here
polymorphism and Inheritance plays the main role. Here actually you are passing the Sub Class object to the Super class reference like below,
if you do A a = new B(); then you can able to get Super class methods only(ofcourse, includes the methods after overriding but not methods belongs to Class B which is not part of overriding).
In jave if you see the collections then you can understand this, ex List ls = new ArrayList();