Constructors and Destructors

Q1:
Which of the following constructor is used in the program given below?
#include<iostream.h> 
class AptitudeCrack
{
    int x, y; 
    public:
    AptitudeCrack(int xx = 10, int yy = 20 )
    {
        x = xx; 
        y = yy;
    }
    void Display()
    {
        cout<< x << ' ' << y << endl;
    } 
    ~AptitudeCrack()
    { } 
};
int main()
{
    AptitudeCrack objAptitude; 
    objAptitude.Display(); 
    return 0;
}

A Copy constructor

B Simple constructor

C Non-parameterized constructor

D Default constructor

ANS:A - Copy constructor

Answer is 'Default Constructor' because object with no argument is created for class AptitudeCrack. And in AptitudeCrack class there is a constructor with default values means it is default constructor.  



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.