No, it won't execute.
If you write
A obj1 = new B();
, it will execute.
Why?
Because,
A
is the base class and
B
is the class that extends
B
. So, according to OOP,
B
"is a"
A
as
A
is in upper position in the inheritance hirarchy. So, it is always possible to assign an object of
B
to a reference of
A
. But, the opposite wouln't execute.
However, If you cast the object as follows, then it will compile, but, won't execute:
B obj1 = (B)new A();