Oracle Java Tutorials, Multiple Inheritance of State, Implementation, and Type:
One reason why the Java programming language does not permit you to extend more than one class is to avoid the issues of multiple inheritance of state, which is the ability to inherit fields from multiple classes. For example, suppose that you are able to define a new class that extends multiple classes. When you create an object by instantiating that class, that object will inherit fields from all of the class's superclasses. What if methods or constructors from different superclasses instantiate the same field?
Couldn't this problem be easily solved by assigning priorities to all the classes a subclass extends?
class A extends B,C,D
{
}
Let us assume that priority was assigned in the ascending order in which they are mentioned in declaration of subclass .
Then priority of B < priority of C < priority of D . So if there is any state or behaviour common to any of these classes B ,C or D then priority decides what should be inherited and what should be hided.
Please advise. Thanks in advance.
Yes, roughly speaking, this how Scala supports extending a class with multiple Traits
"priorities" are determined based on a linearization equation, similar to what you mentioned so there is no ambiguity.