1.

Explain Why Ambiguity Potentially Exists With Multiple Inheritance?

Answer»

A class inherits the variables and methods of all its immediate super classes. Thus it COULD inherit a variable or method of the same name from more than ONE super-class. When that particular variable or method of an object of the sub-class is referenced, there is an ambiguity regarding which of the super classes provides the INHERITANCE.

For INSTANCE, let there be classes teacher and student, both having a variable department. If a class teaching Assistant inherits from both of these classes, any REFERENCE to the department variable of a teaching Assistant object is ambiguous.

A class inherits the variables and methods of all its immediate super classes. Thus it could inherit a variable or method of the same name from more than one super-class. When that particular variable or method of an object of the sub-class is referenced, there is an ambiguity regarding which of the super classes provides the inheritance.

For instance, let there be classes teacher and student, both having a variable department. If a class teaching Assistant inherits from both of these classes, any reference to the department variable of a teaching Assistant object is ambiguous.



Discussion

No Comment Found

Related InterviewSolutions