Question 0-9

Describe a problem with multiple inheritance that Java's concept of interface avoids.

Solution

Multiple inheritance leads to the possibility of multiply inheriting an instance variable, as in the diamond problem. Approaches for resolving such multiple definitions differ. Java prohibits instance variables in interfaces, so although a class may implement multiple interfaces, this cannot lead to the same problem as encountered via multiple inheritance.

Back to Exam 0