2
In the context of inheritance, when B
is sub-class of A
, an instance of B
can be used anywhere where an A
is valid. This is the characteristic of polymorphism. However I have a question.
I know it’s right:
A oa = new A();
B ob = new B();
A oab = new B();
However, this is also correct?
B oba = new A();
And if it is, I’d like to know why.
Thank you! I get it :)
– CSAnimor