Multiple Inheritance Characteristics in C++ G)+ C++, which type of inheritance allows a...
Fujitsu technical mcq question, verified with a worked answer. Free to practise - no sign-up.
Multiple Inheritance Characteristics in C++ G)+ C++, which type of inheritance allows a class to inherit properties and behaviors from multiple base classes? - A) Single Inheritance - B) Multiple Inheritance - C) Multilevel Inheritance - D) Hierarchical Inheritance
Show answer & explanation
Answer: B. Multiple Inheritance
Multiple inheritance is a feature in C++ that allows a derived class to have more than one direct base class, enabling it to inherit attributes and methods from all of them simultaneously.
Step-by-step Derivation:
Step 1: Analyze the definitions of the provided inheritance types.
- Single Inheritance: A derived class inherits from only one base class.
- Multiple Inheritance: A derived class inherits from two or more base classes.
- Multilevel Inheritance: A derived class inherits from a base class, which in turn inherits from another base class (forming a chain).
- Hierarchical Inheritance: Multiple derived classes inherit from a single base class.
Step 2: Match the requirement 'inherit properties and behaviors from multiple base classes' to the definitions.
Step 3: The definition of Multiple Inheritance exactly matches the requirement.
Step 4: Conclusion: Option B is the correct answer.