MCQOPTIONS
Bookmark
Saved Bookmarks
→
Technical MCQs
→
2D Transformation And Answers in Technical MCQs
→
C++ Inheritance relationship is?..
1.
C++ Inheritance relationship is?
A.
Association
B.
Is-A
C.
Has-A
D.
None of the above
E.
Answer» C. Has-A
Show Answer
Discussion
No Comment Found
Post Comment
Related MCQs
C++ Inheritance relationship is?
<pre class="result notranslate">#include <iostream>using namespace std; class Base{public: int lfc() { cout << "Base::lfc() called"; } int lfc(int i) { cout << "Base::lfc(int i) called"; }}; class Derived: public Base{public: int lfc() { cout << "Derived::lfc() called"; }}; int main(){ Derived d; d.lfc(5); return 0;}</pre>19.___________ inheritance may lead to duplication of inherited members from a "grandparent" base class.
<pre class="result notranslate">#include <iostream>using namespace std;class Base {};class Derived: public Base {}; int main(){ Base *p = new Derived; Derived *q = new Base;}</pre>18.What will be the output of the following program?
<pre class="result notranslate"> Note:Includes all required header filesusing namespace std; class base { int arr[15];}; class b1: public base { }; class b2: public base { }; class derived: public b1, public b2 {}; int main(void){ cout << sizeof(derived); return 0;}</pre>17.What will be the output of this program?
<pre class="result notranslate"> Note:Includes all required header filesusing 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;} </pre>16.Assume that an integer takes 2 bytes and there is no alignment in following classes, predict the output.
<pre class="result notranslate"> Note:Includes all required header filesusing 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;} </pre>15.Which of the following is true about the following program
<pre class="result notranslate"> Note:Includes all required header files 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; } </pre>14.What is the output of this program?
<pre class="result notranslate"> Note:Includes all required header files using namespace std; int main() { string s = "a long string"; s.insert(s.size() / 2, " * "); cout << s << endl; return 0; }</pre>13.What is the output of this program?
<pre class="result notranslate"> Note:Includes all required header files using namespace std; class Base { public: Base(){} ~Base(){} protected: private: }; class Derived:public Base { public: Derived(){} Derived(){} private: protected: }; int main() { cout << "Executed" << endl; } </pre>12.What is the output of this program?
Reply to Comment
×
Name
*
Email
*
Comment
*
Submit Reply