A obj = new B();
you're constructing an object
obj
that can do the job of either a B or a A.
B is inherited from A. This way you can access all the properties and methods of A.
And found this
here[
^]:
This is the basis for polymorphism: Imagine you have several child classes that inherit from you parent class. You want to use all these child classes through the interface / methods defined on your parent class, without worrying about the implementation details in each child class (each might do something different, but with the same overall semantics).
This is possible because the child class has a
IS-A relationship with its parent class since child inherits from parent.
I'd suggest you to learn Inheritance & Polymorphism,
https://www.cs.utexas.edu/~scottm/cs307/handouts/InheritanceExplanation.htm[
^]
http://www.c-sharpcorner.com/UploadFile/pcurnow/polymorphcasting06222007131659PM/polymorphcasting.aspx[
^]
-KR