If I have 4 distinct Java types (call them A B C D
), and A
is a subtype of B
and A
is a subtype of C
and B
is a subtype of D
and C
is a subtype of D
, is this legal? Are there any examples out there?
Drawing the diagram:
D
| |
| |
B C
| |
| |
A
So D is the supertype. Thanks!
This is not legal with inheritance, as Java as a language does not support multiple inheritance.
However you can do this by implementing multiple interfaces, which is a different thing from multiple inheritance.
So yes it's possible and for you to do this so far as you can check if something is an instance of an interface but this is not the same as a class type, and your diagram would look a tad different to the one you have drawn.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With