Constructors and Destructors

Q1: What will be the output of the following program?
#include<iostream.h>
class AptitudeBase
{   
    public:
    AptitudeBase()
    {
        cout<< 'Base OK. '; 
    }
    ~AptitudeBase()
    {
        cout<< 'Base DEL. '; 
    }
};
class AptitudeDerived: public AptitudeBase
{
    public:
    AptitudeDerived()
    { 
        cout<< 'Derived OK. '; 
    }
    ~AptitudeDerived()
    { 
        cout<< 'Derived DEL. '; 
    }
};
int main()
{
    AptitudeBase *basePtr = new AptitudeDerived();
    delete basePtr;
    return 0;
}

A Base OK. Derived OK.

B Base OK. Derived OK. Base DEL.

C Base OK. Derived OK. Derived DEL.

D Base OK. Derived OK. Derived DEL. Base DEL.

E Base OK. Derived OK. Base DEL. Derived DEL.

ANS:B - Base OK. Derived OK. Base DEL.

No answer description is available. Let's discuss.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.