Class Object
is the root of class hierarchy. Every class has Object
as a superclass. So, if I am extending a API class, will it be like, multiple inheritance? Obviously, Java doesn't support multiple inheritance. How does it then work?
Superclass is not the same thing as parent class. You can only have one mother, but you have a much larger number of female ancestors.
Java doesn't support multiple inheritance, as everyone else explained.
But you can (kind of) have multiple inheritance when you implement multiple interfaces:
interface Moveable {
void relocate(Coordinate position);
Coordinate getCurrentPos();
}
interface Tradeable {
void sell(BigInteger amount);
void buy(BigInteger amount);
}
interface Crashable {
void crash();
}
class Vehicle implements Moveable, Tradeable, Crashable {
}
Now Vehicle
should all methods from the interfaces it implements.
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