Let's say I have 2 interfaces here, Moveable
and Walkable
(sorry for the bad example, but please if you have a better one kindly post it)
interface Runnable{
void run();
}
interface Walkable extends Runnable {
void walk();
}
public class Human implements Walkable {
}
And the interface Walkable
is a subclass of Runnable
, when the Human
class implements the Walkable
interface should the Human
class provide implementations for void walk()
from the interface Walkable
and void run()
from the interface Runnable
? does the interface Walkable
inherit the abstract method run()
from the interface Runnable
?
Yes, your Human class will need to implement both the walk() and run() methods.
should the human class provide implementations for void walk from the interface walkable and void run() from the interface runnable?
Yes , when your Walkable
interface extends Runnable
it also inherits run
method means now if Human
class is implementing Walkable
interface it has to implement both the methods otherwise it should be abstract
.
Implementing an Interface
is a contract where Implementing class has to implement all the methods declared in Interface.
does the interface Walkable inherit the abstract method run() from the interface Runnable?
Yes, It is the OOPS Inheritance
concept.
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