Functions

Q1: What will be the output of the following program?
#include<iostream.h> 
class Base
{
    public:
    int S, A, M; 
    Base(int x, int y)
    {
        S = y - y;
        A = x + x; 
        M = x * x;
    }
    Base(int, int y = 'A', int z = 'B')
    {
        S = y;
        A = y + 1 - 1; 
        M = z - 1;
    }
    void Display(void)
    {
        cout<< S << ' ' << A << ' ' << M << endl;
    }
};
class Derived : public Base
{
    int x, y, z; 
    public:
    Derived(int xx = 65, int yy = 66, int zz = 67): Base(x)
    {
        x = xx; 
        y = yy;
        z = zz;
    }
    void Display(int n)
    {
        if(n)
            Base::Display(); 
        else
            cout<< x << ' ' << y << ' ' << z << endl; 
    }
};
int main()
{
    Derived objDev; 
    objDev.Display(-1); 
    return 0;
}

A A A A

B A B C

C 65 66 67

D The program will report compile time error.

E 65 65 65

ANS:A - 65 65 65

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.