Which casting among the following is allowed for the code given below?
class A
{
public :int a;
}
class B:public A
{
int b;
}
main()
{
B b=new A(); //casting 1
A a=new B(); //casting 2
}
- Casting 1
- Casting 2
- casting 1 and casting 2
- casting 1 nor casting 2
(b).Casting 2
need an explanation for this answer? contact us directly to get an explanation for this answer