LakshyaEducation.in

VEDIC MATHS Video Series
  • Home
  • Video Series
    • Vedic Maths Videos
    • Quantitative Aptitude Videos
    • Class 8 Maths Videos
    • Class 9 Maths Videos
    • Class 10 Maths Videos
  • Quiz & Solutions
  • Blog
  • Store
  • Login
  • Contact Us
  • Home
  • Topic
  • C++ Programming
  • Multiple Inheritance

C++ Programming

MULTIPLE INHERITANCE MCQs

Total Questions : 10

Question 1.

What are the things are inherited from the base class?


  1.    Constructor and its destructor
  2.    Operator=() members
  3.    Friends
  4.    All of the mentioned
 Discuss Question
Answer is Option D. -> All of the mentioned

These things can provide necessary information for the base class to make a logical decision.

Question 2.

Which design patterns benefit from the multiple inheritance?


  1.    Adapter and observer pattern
  2.    Code pattern
  3.    Glue pattern
  4.    None of the mentioned
 Discuss Question
Answer is Option A. -> Adapter and observer pattern

None.

Question 3.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
class Base1
4.
{
5.
protected:
6.
int SampleDataOne;
7.
public:
8.
Base1()
9.
{
10.
SampleDataOne = 100;
11.
}
12.
~Base1()
13.
{
14.
}
15.
int SampleFunctOne()
16.
{
17.
return SampleDataOne;
18.
}
19.
};
20.
class Base2
21.
{
22.
protected:
23.
int SampleDataTwo;
24.
public:
25.
Base2()
26.
{
27.
SampleDataTwo = 200;
28.
}
29.
~Base2()
30.
{
31.
}
32.
int SampleFunctTwo()
33.
{
34.
return SampleDataTwo;
35.
}
36.
};
37.
class Derived1 : public Base1, public Base2
38.
{
39.
int MyData;
40.
public:
41.
Derived1()
42.
{
43.
MyData = 300;
44.
}
45.
~Derived1()
46.
{
47.
}
48.
int MyFunct()
49.
{
50.
return (MyData + SampleDataOne + SampleDataTwo);
51.
}
52.
};
53.
int main()
54.
{
55.
Base1 SampleObjOne;
56.
Base2 SampleObjTwo;
57.
Derived1 SampleObjThree;
58.
cout
  1.    100
  2.    200
  3.    Both a & b
  4.    None of the mentioned
 Discuss Question
Answer is Option C. -> Both a & b

In this program, We are passing the values by using multiple inheritance and printing the derived values.
Output:
$ g++ mul4.cpp
$ a.out
100
200

Question 4.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
struct a
4.
{
5.
int count;
6.
};
7.
struct b
8.
{
9.
int* value;
10.
};
11.
struct c : public a, public b
12.
{
13.
};
14.
int main()
15.
{
16.
c* p = new c;
17.
p->value = 0;
18.
cout
  1.    Inherited
  2.    Error
  3.    Runtime error
  4.    None of the mentioned
 Discuss Question
Answer is Option A. -> Inherited

In this program, We apply the multiple inheritance to structure.
Output:
$ g++ mul2.cpp
$ a.out
Inherited

Question 5.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
class student
4.
{
5.
public:
6.
int rno , m1 , m2 ;
7.
void get()
8.
{
9.
rno = 15, m1 = 10, m2 = 10;
10.
}
11.
};
12.
class sports
13.
{
14.
public:
15.
int sm;
16.
void getsm()
17.
{
18.
sm = 10;
19.
}
20.
};
21.
class statement:public student,public sports
22.
{
23.
int tot,avg;
24.
public:
25.
void display()
26.
{
27.
tot = (m1 + m2 + sm);
28.
avg = tot / 3;
29.
cout
  1.    3100
  2.    3010
  3.    2010
  4.    1010
 Discuss Question
Answer is Option B. -> 3010

In this program, We are calculating the total and average marks of a student by using multiple inheritance.
Output:
$ g++ mul1.cpp
$ a.out
3010

Question 6.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
class Base
4.
{
5.
public:
6.
virtual void print() const = 0;
7.
};
8.
class DerivedOne : public Base
9.
{
10.
public:
11.
void print() const
12.
{
13.
cout
  1.    DerivedOne
  2.    DerivedTwo
  3.    Error
  4.    None of the mentioned
 Discuss Question
Answer is Option C. -> Error

In this program, 'Base' is an ambiguous base of 'Multiple'. So it is producing an error. And this 

program is a virtual base class.

Question 7.

Which of the following advantages we lose by using multiple inheritance?


  1.    Dynamic binding
  2.    Polymorphism
  3.    Both a & b
  4.    None of the mentioned
 Discuss Question
Answer is Option C. -> Both a & b

The benefit of dynamic binding and polymorphism is that they help making the code easier to 

extend but by multiple inheritance it makes harder to track.

Question 8.

Which symbol is used to create multiple inheritance?


  1.    Dot
  2.    Comma
  3.    Dollar
  4.    None of the mentioned
 Discuss Question
Answer is Option B. -> Comma

For using multiple inheritance, simply specify each base class (just like in single inheritance), 

separated by a comma.

Question 9.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
class polygon
4.
{
5.
protected:
6.
int width, height;
7.
public:
8.
void set_values (int a, int b)
9.
{
10.
width = a; height = b;}
11.
};
12.
class output1
13.
{
14.
public:
15.
void output (int i);
16.
};
17.
void output1::output (int i)
18.
{
19.
cout
  1.    DerivedOne
  2.    DerivedTwo
  3.    Error
  4.    None of the mentioned
 Discuss Question
Answer is Option C. -> Error

Answer:c
Explanation:
We are using the multiple inheritance to find the area of rectangle and triangle.
Output:
$ g++ mul.cpp
$ a.out
20
10

Question 10.

What is meant by multiple inheritance?


  1.    Deriving a base class from derived class
  2.    Deriving a derived class from base class
  3.    Deriving a derived class from more than one base class
  4.    None of the mentioned
 Discuss Question
Answer is Option C. -> Deriving a derived class from more than one base class

Multiple inheritance enables a derived class to inherit members from more than one parent.

  • Share on Facebook!
  • Share on Pinterest!

Sub Topics

  • Abstract Classes
  • Access Control
  • Argument Passing
  • Arrays
  • Booleans
  • C++ Concepts
  • Catching Exceptions
  • Character Types
  • Class Hierarchies And Abstract Classes
  • Class Hierarchies Introduction
  • Classes
  • Comments And Indentation
  • Complex Number Type
  • Constants
  • Constructors And Destructors
  • Container Design
  • Conversion Operators
  • Declaration
  • Default Arguments
  • Dereferencing
  • Derivation And Templates
  • Derived Classes
  • Design Of Class Hierarchies
  • Enumerations
  • Error Handling
  • Error Handling Alternatives
  • Essential Operators
  • Exception Specifications
  • Exceptions
  • Exceptions And Efficiency
  • Exceptions That Are Not Errors
  • Floating Point Types
  • Free Store
  • Friends
  • Function Call
  • Function Declarations
  • Function Templates
  • Functions
  • Grouping Of Exceptions
  • Header Files Usage
  • Increment And Decrement
  • Integer Types
  • Large Objects
  • Linkage
  • Macros
  • Modularization And Interfaces
  • Multiple Inheritance
  • Namespaces
  • Objects
  • Objects And Classes
  • Oops Concepts
  • Operator Functions
  • Operators
  • Overloaded Function Names
  • Pointer To Function
  • Pointer To Void
  • Pointers
  • Pointers Into Arrays
  • Pointers To Members
  • References
  • Resource Management
  • Run Time Type Information
  • Sequence Adapters
  • Sequences
  • Simple String Template
  • Sizes
  • Specialization
  • Standard Exceptions
  • Standard Library Design
  • Statements
  • String Class
  • Structures
  • Subscripting
  • Template Arguments To Specify Policy Usage
  • Types
  • Uncaught Exceptions
  • Unspecified Number Of Arguments
  • User Defined Types
  • Value Return
  • Vector
  • Void

Topics

  • Computer Aptitude
  • SAIL Junior Officer (E-0)
  • 10th Grade
  • 11th Grade
  • 12th Grade
  • 4th Grade
  • 5th Grade
  • 6th Grade
  • 7th Grade
  • 8th Grade
  • 9th Grade
  • NCERT
  • Cat
  • Commerce
  • Computer Science
  • Engineering
  • English
  • General Knowledge
  • Ias
  • Management
  • Quantitative Aptitude
  • Reasoning Aptitude
  • General Studies (Finance And Economics)
  • Analytical Instrumentation
  • Biochemistry
  • Bioinformatics
  • Biology
  • Biotechnology
  • Bitsat
  • Business Statistics
  • C Programming
  • C++ Programming
  • Cell Biology
  • Chemistry
  • Cost Accounting
  • Drug And Pharmaceutical Biotechnology
  • Electrical Measurement And Instrumentation
  • Environment Management
  • Environmental Biotechnology
  • Enzyme Technology
  • Financial Management And Financial Markets
  • Gate
  • General Science
  • Geography
  • Heat Transfer
  • History And National Movements
  • Human Anatomy And Physiology
  • Human And Cultural Diversity
  • Human Resource Management
  • Indian Economy
  • Indian Geography
  • Indian History
  • Indian Polity
  • Instrumentation Transducers
  • International Relations
  • Life Sciences
  • Marketing And Marketing Management
  • Mass Transfer
  • Mechanics Of Materials
  • Microbiology
  • Neet
  • Professional Communication
  • Renewable Energy
  • Sociology
  • Surveying
  • Total Quality Management
  • Uidai Aadhaar Supervisor Certification
  • Virology

Recent Questions

Q.   The Mortar In Which Both Cement And Lime Are Used As Binding....

Q.   In....

Q.   High Temperature In Gasification Of Coal Favours

Q.   The __________ Engines Can Work On Very Lean Mixture Of Fuel....

Q.   Ch....

Q.   Purification Of Blood Takes Place In

Q.   What Is The Minimum Vapour Pressure (in KPa) Of The Working ....

Q.   The Kaposi’s Sarcoma Is Caused By ____________________

Q.   Neutral Atmosphere Is Maintained In A/an __________ Furnace.....

Q.   Raju Has 14 Currency Notes In His Pocket Consisting Of Only....

Q.   " You Are Thinking Very Highly About Ravi But He Is Not....

Q.   The Range Of Electromagnetic Spectrum Important In Heat Tran....

Q.   Th....

Q.   January : November : : Sunday : ?

Q.   Consider The Following Statements.There Are 25 High Courts I....

Q.   T....

Q.   In Which Type Of Sedimentation, The Flocculent Suspension Of....

Q.   Hardening Of Metal Is Due To Heating To A Particular Temper....

Q.   Which Of The Following Materials Has The Highest Electrical ....

Q.   ....

LakshyaEducation.in
Lakshya Education
Bhilai,Chattisgarh,India
Email: admin@lakshyaeducation.in Phone: 07893519977 (WhatsApp)

Quick Links

  • Vedic Maths
  • Quantitative Aptitude
  • Class – IX Maths
  • Class – X Maths
  • YouTube Channel
  • Maths Fast Trick
  • Blog

Our Services

  • About us
  • Privacy
  • TOS
  • Refund / Cancellation
  • Contact
  • Affiliate Program
  • Copyright © 2022 All Right Reserved | Lakshya Education     ( )
    Login / Register

    Your Account will be created automatically when you click the below Google or Facebook Login Button.
    •   Login With Facebook
    •  Login With Google
     Login With Email/Password