Inheritance In C Plus Plus — Part 2 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Inheritance In C Plus Plus — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
34
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
41 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
34
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/34 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 34 questions answered.
Question 1 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class Mammal { public: Mammal(){ cout<<"I'm a Mammal\n"; } ~Mammal(){} }; class Human: public Mammal { public: Human(){ cout<<"I'm a Human\n"; } ~Human(){} }; class Male: public Human { public: Male(){ cout<<"I'm a Male\n"; } ~Male(){} }; class Female: public Human { public: Female(){ cout<<"I'm a Female\n"; } ~Female(){} }; int main(int argc, char const *argv[]) { Male M; return 0; }
Correct Answer: Option A — I'm a Mammal I'm a Human I'm a Male
Detailed Academic Explanation:
I'm a Mammal I'm a Human I'm a Male is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class Mammal { public: Mammal(){ cout<<"I'm a Mammal\n"; } ~Mammal(){} }; class Human: public Mammal { public: Human(){ cout<<"I'm a Human\n"; } ~Human(){} }; class Male: public Human { public: Male(){ cout<<"I'm a Male\n"; } ~Male(){} }; class Female: public Human { public: Female(){ cout<<"I'm a Female\n"; } ~Female(){} }; int main(int argc, char const *argv[]) { Male M; return 0; }”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 2 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { float d; public: virtual void func(){ cout<<"Hello this is class A\n"; } }; class B: public A { int a = 15; public: void func(){ cout<<"Hello this is class B\n"; } }; int main(int argc, char const *argv[]) { A *a; a->func(); return 0; }
Correct Answer: Option D — Segmentation Fault
Detailed Academic Explanation:
Segmentation Fault is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { float d; public: virtual void func(){ cout<<"Hello this is class A\n"; } }; class B: public A { int a = 15; public: void func(){ cout<<"Hello this is class B\n"; } }; int main(int argc, char const *argv[]) { A *a; a->func(); return 0; }”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 3 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which statement is incorrect about virtual function.
Correct Answer: Option B — They are used to hide objects
Detailed Academic Explanation:
They are used to hide objects is the correct answer to “Which statement is incorrect about virtual function.”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 4 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { int a; public: A(){ a = 0; } void show(){ a++; cout<<"a: "<<a<<endl; } }; class B: public A { public: }; int main(int argc, char const *argv[]) { B b; b.show(); return 0; }
Correct Answer: Option A — a: 1
Detailed Academic Explanation:
a: 1 is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { int a; public: A(){ a = 0; } void show(){ a++; cout<<"a: "<<a<<endl; } }; class B: public A { public: }; int main(int argc, char const *argv[]) { B b; b.show(); return 0; }”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 5 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which is the correct syntax of declaring a virtual function?
Correct Answer: Option A — virtual int func()
Detailed Academic Explanation:
virtual int func() is the correct answer to “Which is the correct syntax of declaring a virtual function”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 6 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { int a; public: A(){ a = 0; } static void show(){ a++; cout<<a; } }; class B: public A { public: }; int main(int argc, char const *argv[]) { B b; b.show(); return 0; }
Correct Answer: Option D — Error
Detailed Academic Explanation:
Error is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { int a; public: A(){ a = 0; } static void show(){ a++; cout<<a; } }; class B: public A { public: }; int main(int argc, char const *argv[]) { B b; b.show(); return 0; }”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 7 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { public: virtual A(){ cout<<"A's Constructor\n"; } }; class B: public A { public: A(){ cout<<"Present inside the class B\n"; } }; int main(int argc, char const *argv[]) { A a; return 0; }
Correct Answer: Option C — Error
Detailed Academic Explanation:
Error is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { public: virtual A(){ cout<<"A's Constructor\n"; } }; class B: public A { public: A(){ cout<<"Present inside the class B\n"; } }; int main(int argc, char const *argv[]) { A a; return 0; }”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 8 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What happens if the following C++ program is compiled? #include <iostream> #include <string> using namespace std; class A { int a; public: A(){ a = 0; } void show(){ a++; cout<<"a: "<<a<<endl; } }; class B: private A { public: void show(){ show(); } }; int main(int argc, char const *argv[]) { B b; b.show(); return 0; }
Correct Answer: Option B — Program will compile successfully
Detailed Academic Explanation:
Program will compile successfully is the correct answer to “What happens if the following C++ program is compiled? #include <iostream> #include <string> using namespace std; class A { int a; public: A(){ a = 0; } void show(){ a++; cout<<"a: "<<a<<endl; } }; class B: private A { public: void show(){ show(); } }; int main(int argc, char const *argv[]) { B b; b.show(); return 0; }”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 9 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; class Base { public: virtual void print() const = 0; }; class DerivedOne : public Base { public: void print() const { cout << "DerivedOne\n"; } }; class DerivedTwo : public Base { public: void print() const { cout << "DerivedTwo\n"; } }; class Multiple : public DerivedOne, public DerivedTwo { public: void print() const { DerivedTwo :: print(); } }; int main() { int i; Multiple both; DerivedOne one; DerivedTwo two; Base *array[ 3 ]; array[ 0 ] = &both; array[ 1 ] = &one; array[ 2 ] = &two; array[ i ] -> print(); return 0; }
Correct Answer: Option C — Error
Detailed Academic Explanation:
Error is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; class Base { public: virtual void print() const = 0; }; class DerivedOne : public Base { public: void print() const { cout << "DerivedOne\n"; } }; class DerivedTwo : public Base { public: void print() const { cout << "DerivedTwo\n"; } }; class Multiple : public DerivedOne, public DerivedTwo { public: void print() const { DerivedTwo :: print(); } }; int main() { int i; Multiple both; DerivedOne one; DerivedTwo two; Base *array[ 3 ]; array[ 0 ] = &both; array[ 1 ] = &one; array[ 2 ] = &two; array[ i ] -> print(); return 0; }”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 10 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which design patterns benefit from the multiple inheritances?
Correct Answer: Option A — Adapter and observer pattern
Detailed Academic Explanation:
Adapter and observer pattern is the correct answer to “Which design patterns benefit from the multiple inheritances”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 11 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { public: virtual static void show(){ cout<<"class A\n"; } }; class B: public A { public: static void show(){ cout<<"class B\n"; } }; int main(int argc, char const *argv[]) { A *a = new A(); B b; a = &b; a->show(); return 0; }
Correct Answer: Option B — Error
Detailed Academic Explanation:
Error is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { public: virtual static void show(){ cout<<"class A\n"; } }; class B: public A { public: static void show(){ cout<<"class B\n"; } }; int main(int argc, char const *argv[]) { A *a = new A(); B b; a = &b; a->show(); return 0; }”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 12 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { float d; public: A(){ cout<<"Constructor of class A\n"; } }; class B: public A { int a = 15; public: B(){ cout<<"Constructor of class B\n"; } }; int main(int argc, char const *argv[]) { B b; return 0; }
Correct Answer: Option A — Constructor of class A Constructor of class B
Detailed Academic Explanation:
Constructor of class A Constructor of class B is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { float d; public: A(){ cout<<"Constructor of class A\n"; } }; class B: public A { int a = 15; public: B(){ cout<<"Constructor of class B\n"; } }; int main(int argc, char const *argv[]) { B b; return 0; }”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 13 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; class student { public: int rno , m1 , m2 ; void get() { rno = 15, m1 = 10, m2 = 10; } }; class sports { public: int sm; void getsm() { sm = 10; } }; class statement:public student,public sports { int tot,avg; public: void display() { tot = (m1 + m2 + sm); avg = tot / 3; cout << tot; cout << avg; } }; int main() { statement obj; obj.get(); obj.getsm(); obj.display(); }
Correct Answer: Option B — 3010
Detailed Academic Explanation:
3010 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; class student { public: int rno , m1 , m2 ; void get() { rno = 15, m1 = 10, m2 = 10; } }; class sports { public: int sm; void getsm() { sm = 10; } }; class statement:public student,public sports { int tot,avg; public: void display() { tot = (m1 + m2 + sm); avg = tot / 3; cout << tot; cout << avg; } }; int main() { statement obj; obj.get(); obj.getsm(); obj.display(); }”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 14 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is a pure virtual function?
Correct Answer: Option B — A virtual function that has no definition relative to the base class
Detailed Academic Explanation:
A virtual function that has no definition relative to the base class is the correct answer to “What is a pure virtual function”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 15 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class Mammal { public: virtual void Define(){ cout<<"I'm a Mammal\n"; } }; class Human: public Mammal { public: void Define(){ cout<<"I'm a Human\n"; } }; class Male: public Human { public: void Define(){ cout<<"I'm a Male\n"; } }; class Female: public Human { public: void Define(){ cout<<"I'm a Female\n"; } }; int main(int argc, char const *argv[]) { Mammal *M = new Mammal(); Male m; Female f; *M = m; M->Define(); M = &m; M->Define(); return 0; }
Correct Answer: Option C — I'm a Mammal I'm a Male
Detailed Academic Explanation:
I'm a Mammal I'm a Male is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class Mammal { public: virtual void Define(){ cout<<"I'm a Mammal\n"; } }; class Human: public Mammal { public: void Define(){ cout<<"I'm a Human\n"; } }; class Male: public Human { public: void Define(){ cout<<"I'm a Male\n"; } }; class Female: public Human { public: void Define(){ cout<<"I'm a Female\n"; } }; int main(int argc, char const *argv[]) { Mammal *M = new Mammal(); Male m; Female f; *M = m; M->Define(); M = &m; M->Define(); return 0; }”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 16 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; struct a { int count; }; struct b { int* value; }; struct c : public a, public b { }; int main() { c* p = new c; p->value = 0; cout << "Inherited"; return 0; }
Correct Answer: Option A — Inherited
Detailed Academic Explanation:
Inherited is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; struct a { int count; }; struct b { int* value; }; struct c : public a, public b { }; int main() { c* p = new c; p->value = 0; cout << "Inherited"; return 0; }”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 17 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; class Base1 { protected: int SampleDataOne; public: Base1() { SampleDataOne = 100; } ~Base1() { } int SampleFunctOne() { return SampleDataOne; } }; class Base2 { protected: int SampleDataTwo; public: Base2() { SampleDataTwo = 200; } ~Base2() { } int SampleFunctTwo() { return SampleDataTwo; } }; class Derived1 : public Base1, public Base2 { int MyData; public: Derived1() { MyData = 300; } ~Derived1() { } int MyFunct() { return (MyData + SampleDataOne + SampleDataTwo); } }; int main() { Base1 SampleObjOne; Base2 SampleObjTwo; Derived1 SampleObjThree; cout << SampleObjThree.Base1 :: SampleFunctOne() << endl; cout << SampleObjThree.Base2 :: SampleFunctTwo() << endl; return 0; }
Correct Answer: Option C — Both 100 & 200
Detailed Academic Explanation:
Both 100 & 200 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; class Base1 { protected: int SampleDataOne; public: Base1() { SampleDataOne = 100; } ~Base1() { } int SampleFunctOne() { return SampleDataOne; } }; class Base2 { protected: int SampleDataTwo; public: Base2() { SampleDataTwo = 200; } ~Base2() { } int SampleFunctTwo() { return SampleDataTwo; } }; class Derived1 : public Base1, public Base2 { int MyData; public: Derived1() { MyData = 300; } ~Derived1() { } int MyFunct() { return (MyData + SampleDataOne + SampleDataTwo); } }; int main() { Base1 SampleObjOne; Base2 SampleObjTwo; Derived1 SampleObjThree; cout << SampleObjThree.Base1 :: SampleFunctOne() << endl; cout << SampleObjThree.Base2 :: SampleFunctTwo() << endl; return 0; }”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 18 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following advantages we lose by using multiple inheritances?
Correct Answer: Option C — Both Dynamic binding & Polymorphism
Detailed Academic Explanation:
Both Dynamic binding & Polymorphism is the correct answer to “Which of the following advantages we lose by using multiple inheritances”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 19 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { int a; public: A(){ a = 0; } void show(){ a++; cout<<"a: "<<a<<endl; } }; class B: private A { public: }; int main(int argc, char const *argv[]) { B b; b.show(); return 0; }
Correct Answer: Option A — Error
Detailed Academic Explanation:
Error is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { int a; public: A(){ a = 0; } void show(){ a++; cout<<"a: "<<a<<endl; } }; class B: private A { public: }; int main(int argc, char const *argv[]) { B b; b.show(); return 0; }”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 20 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is a virtual function in C++?
Correct Answer: Option D — All the functions which are declared in the base class and is re-defined/overridden by the derived class
Detailed Academic Explanation:
All the functions which are declared in the base class and is re-defined/overridden by the derived class is the correct answer to “What is a virtual function in C++”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 21 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { float d; public: int a; void change(int i){ a = i; } void value_of_a(){ cout<<a; } }; class B: public A { int a = 15; public: void print(){ cout<<a; } }; int main(int argc, char const *argv[]) { B b; b.change(10); b.print(); b.value_of_a(); return 0; }
Correct Answer: Option B — 1510
Detailed Academic Explanation:
1510 is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { float d; public: int a; void change(int i){ a = i; } void value_of_a(){ cout<<a; } }; class B: public A { int a = 15; public: void print(){ cout<<a; } }; int main(int argc, char const *argv[]) { B b; b.change(10); b.print(); b.value_of_a(); return 0; }”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 22 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class Mammal { public: virtual void Define(){ cout<<"I'm a Mammal\n"; } }; class Human: public Mammal { private: void Define(){ cout<<"I'm a Human\n"; } }; int main(int argc, char const *argv[]) { Mammal *M = new Mammal(); Human H; M = &H; M->Define(); return 0; }
Correct Answer: Option C — I'm a Human
Detailed Academic Explanation:
I'm a Human is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class Mammal { public: virtual void Define(){ cout<<"I'm a Mammal\n"; } }; class Human: public Mammal { private: void Define(){ cout<<"I'm a Human\n"; } }; int main(int argc, char const *argv[]) { Mammal *M = new Mammal(); Human H; M = &H; M->Define(); return 0; }”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 23 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which concept of OOPs is shown by Virtual Functions?
Correct Answer: Option C — Polymorphism
Detailed Academic Explanation:
Polymorphism is the correct answer to “Which concept of OOPs is shown by Virtual Functions”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 24 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Virtual functions in C++ tells the compiler to perform . . . . . . . . on such functions.
Correct Answer: Option B — late binding
Detailed Academic Explanation:
late binding is the correct answer to “Virtual functions in C++ tells the compiler to perform . . . . . . . . on such functions.”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 25 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The concept of deciding which function to invoke during runtime is called . . . . . . . .
Correct Answer: Option D — both late binding and dynamic linkage
Detailed Academic Explanation:
both late binding and dynamic linkage is the correct answer to “The concept of deciding which function to invoke during runtime is called . . . . . . . .”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 26 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the order of Destructors call when the object of derived class B is declared, provided class B is derived from class A?
Correct Answer: Option B — Destructor of B followed by A
Detailed Academic Explanation:
Destructor of B followed by A is the correct answer to “What is the order of Destructors call when the object of derived class B is declared, provided class B is derived from class A”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 27 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { int a, b; float d; public: void change(int i){ a = i; } void value_of_a(){ cout<<a; } }; class B: private A { }; int main(int argc, char const *argv[]) { B b; cout<<sizeof(B); return 0; }
Correct Answer: Option B — 12
Detailed Academic Explanation:
12 is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { int a, b; float d; public: void change(int i){ a = i; } void value_of_a(){ cout<<a; } }; class B: private A { }; int main(int argc, char const *argv[]) { B b; cout<<sizeof(B); return 0; }”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 28 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What are the things are inherited from the base class?
Correct Answer: Option D — All of the mentioned
Detailed Academic Explanation:
All of the mentioned is the correct answer to “What are the things are inherited from the base class”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 29 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the order of Constructors call when the object of derived class B is declared, provided class B is derived from class A?
Correct Answer: Option A — Constructor of A followed by B
Detailed Academic Explanation:
Constructor of A followed by B is the correct answer to “What is the order of Constructors call when the object of derived class B is declared, provided class B is derived from class A”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 30 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; class polygon { protected: int width, height; public: void set_values (int a, int b) { width = a; height = b;} }; class output1 { public: void output (int i); }; void output1::output (int i) { cout << i << endl; } class rectangle: public polygon, public output1 { public: int area () { return (width * height); } }; class triangle: public polygon, public output1 { public: int area () { return (width * height / 2); } }; int main () { rectangle rect; triangle trgl; rect.set_values (4, 5); trgl.set_values (4, 5); rect.output (rect.area()); trgl.output (trgl.area()); return 0; }
Correct Answer: Option C — 20 10
Detailed Academic Explanation:
20 10 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; class polygon { protected: int width, height; public: void set_values (int a, int b) { width = a; height = b;} }; class output1 { public: void output (int i); }; void output1::output (int i) { cout << i << endl; } class rectangle: public polygon, public output1 { public: int area () { return (width * height); } }; class triangle: public polygon, public output1 { public: int area () { return (width * height / 2); } }; int main () { rectangle rect; triangle trgl; rect.set_values (4, 5); trgl.set_values (4, 5); rect.output (rect.area()); trgl.output (trgl.area()); return 0; }”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 31 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which symbol is used to create multiple inheritances?
Correct Answer: Option B — Comma
Detailed Academic Explanation:
Comma is the correct answer to “Which symbol is used to create multiple inheritances”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 32 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How many specifiers are used to derive a class?
Correct Answer: Option C — 3
Detailed Academic Explanation:
3 is the correct answer to “How many specifiers are used to derive a class”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 33 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
If a class is derived privately from a base class then . . . . . . . .
Correct Answer: Option C — all the members are inherited by the class but are hidden and cannot be accessible
Detailed Academic Explanation:
all the members are inherited by the class but are hidden and cannot be accessible is the correct answer to “If a class is derived privately from a base class then . . . . . . . .”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
Question 34 of 34
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is meant by multiple inheritance?
Correct Answer: Option C — Deriving a derived class from more than one base class
Detailed Academic Explanation:
Deriving a derived class from more than one base class is the correct answer to “What is meant by multiple inheritance”. This question is standard in competitive examination syllabi for Inheritance In C Plus Plus.
💡Key Conceptual Anchor:Inheritance In C Plus Plus
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.