While it's true that a class can directly inherit from at most one other
class (from exactly one other class except for java.lang.Object, which inherits
from exactly zero other classes), a class or an interface can inherit from
multiple interfaces. E.g. "class SoAndSo extends X implements A, B, C", or
"interface HowsThat implements D, E, F".
There are special rules for
handling conflicts due to multiple inheritance. If interface A and
interface B both have a constant with the same name, then class SoAndSo has to
use a qualified name to refer to either of those constants, even though in the
absence of conflict a simple name would suffice. If interface A and
interface B both define a method called "CallMeSometime" with the same signature
but different return types, then no class is allowed to implement, directly or
indirectly both A and B. See the
Java Language Specification, Chapter 8. [ Reply to This | Parent | # ]
|