adplus-dvertising
frame-decoration

Question

What is correct about the following program?
#include<iostream.h> 
class Base
{
    int x, y, z; 
    public: 
    Base()
    {
        x = y = z = 0;
    }
    Base(int xx, int yy = 'A', int zz = 'B')
    {
        x = xx;
        y = x + yy;
        z = x + y;
    }
    void Display(void)
    {
        cout<< x << " " << y << " " << z << endl;
    }
};
class Derived : public Base
{
    int x, y; 
    public:
    Derived(int xx = 65, int yy = 66) : Base(xx, yy)
    {
        y = xx; 
        x = yy;
    }
    void Display(void)
    {
        cout<< x << " " << y << " ";
        Display(); 
    }
};
int main()
{
    Derived objD;
    objD.Display();
    return 0; 
}

a.

The program will report compilation error.

b.

The program will run successfully giving the output 66 65.

c.

The program will run successfully giving the output 65 66.

d.

The program will run successfully giving the output 66 65 65 131 196.

Answer: (c).The program will run successfully giving the output 65 66.

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is correct about the following program?

Similar Questions

Discover Related MCQs

Q. The variable that are listed in the function's calls are called

Q. A programmer can create custom header files that must be end with

Q. Unary scope resolution operator is denoted by

Q. To make large programs more manageable programmers modularize them into subprograms that are called

Q. The maths function acos (x) stands for

Q. Which from the following is not a storage class specifier in C++?

Q. Which of the following function returns no value?

Q. A variable that is declared inside a block is called

Q. For accessing a global variable when a local variable of the same name is in scope, C++ provides a

Q. The () parenthesis in a function call

Q. Modules in C++ are called

Q. Which from the following is used for invoking a function?

Q. There are how many ways to invoke a function in C++?

Q. All variables declared in function definition are called

Q. Which operator is used for accessing global variables if the local variable of same name exists in the code?

Q. A function that need no return value, is called

Q. An identifier's scope is

Q. The standard C library file < stdlib.h> is used for

Q. Not initializing a reference variable will cause

Q. In which circumstances the recursion function is called?