Home › Interview Questions › In class C, you are inheriting from classes A and …

In class C, you are inheriting from classes A and B, right?

🟡 Medium Conceptual Mid level
2Times asked
Jun 2026Last seen
Jun 2026First seen

💡 Model Answer

Yes, class C inherits from both A and B, which is called multiple inheritance. In Python, the method resolution order (MRO) determines the order in which base classes are searched when executing a method. Python uses the C3 linearization algorithm to produce a consistent MRO that respects the inheritance graph and the order of base classes in the class definition. For example, if class C(A, B), the MRO will be C, A, B, object. This ensures that if both A and B define a method with the same name, the one from A will be called first. Multiple inheritance can lead to the diamond problem, where a class inherits from two classes that both inherit from a common ancestor. Python resolves this by ensuring that the common ancestor's constructor is called only once, thanks to super() and the MRO. When designing with multiple inheritance, it’s important to keep the hierarchy simple, use mixins for small, reusable pieces of functionality, and rely on super() to maintain a clean call chain.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.

Get Assisting AI — Starts at ₹500