11.
What is the output of this program?
#include<iostream> using namespace std; class Base { public: Base(){} ~Base(){} protected: private: }; class Derived:public Base { public: Derived(){} Derived(){} private: protected: }; int main() { cout << "Executed" << endl; }
A. Executed
B. Error
C. Runtime error
D. None of the mentioned
12.
____________ members of base class are inaccessible to derived class
A. Private
B. Protected
C. Public
D. None
13.
What is the output of this program?
#include<iostream> using namespace std; struct a { int p; }; struct b { int* x; }; struct c : public a, public b { }; int main() { c *p = new c; p->x = 0; cout << "Inherited"; return 0; }
A. Inherited
B. Error
C. Runtime error
D. None of the mentioned
View Answer
14.
What is the output of this program?
#include<iostream> using namespace std; class Base1 { public: Base1() { cout << " Base1" << endl; } }; class Base2 { public: Base2() { cout << "Base2" << endl; } }; class Derived: public Base1, public Base2 { public: Derived() { cout << "Derived" << endl; } }; int main() { Derived d; return 0; }
A. Compiler Dependent
B. Base1 Base2 Derived
C. Base2 Base1 Derived
D. Compiler Error
15.
Which of the following is true about the following program
#include<iostream> using namespace std; class Base1 { public: ~Base1() { cout << " Base1" << endl; } }; class Base2 { public: ~Base2() { cout << " Base2" << endl; } }; class Derived: public Base1, public Base2 { public: ~Derived() { cout << " Derived" << endl; } }; int main() { Derived d; return 0; }
A. Base1 Base2 Derived
B. Derived Base2 Base1
C. Derived
D. Compiler Dependent