The question is more theoretical than the usual questions on stack overflow. My question is: If class A inherits from class B what is/are the right ways to initialize objects if they both have an empty constructor (no parameters)?
This are the options:
- A a = new B();
- B b = new A();
- A a = new B() as A;
- B b = new A() as B;
I think that both 1 and 3 are possible but I'm really not sure. Can someone explain which are right and why?