Forums Register Login

Interface extending another interface.Why do we need it?

+Pie Number of slices to send: Send
It is a known thing that an interface can extend another interface in java. But why do we need to do it in the first place, can anyone give me a scenario or a reason to do it? Please make me undustand this. I cannot find the benefit of doing it?
+Pie Number of slices to send: Send
For exactly the same reason you would want to extend a normal class.

Let's say you have an interface exposing the methods you can call on a Vehicle object. You can then define a Car interface which extends the Vehicle interface. Every Class which implements the Car interface would then have to implement the methods from the Car interface as well as the Vehicle interface.

You would have to use interfaces (or maybe abstract classes) for the above example as you can not create a Vehicle or a Car (it is not specific enough).
You can't have everything. Where would you put it?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 812 times.
Similar Threads
what is the need of interface????????
NX: Bodgitt and Scarper: may I modify the javadoc of the interface DB.java?
Intepreting the Observer pattern
diff in arraylist n vectort
Can we define run() in another method of the class ??
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 07:53:40.