+ 2
Is it not possible to implements same interface with multiple classes in java ?
I'm new to java and right now i'm learning interface, i learned basic concepts of it. But when i tries to implement same interface with multiple classes it shows errors. You can visit code with following link . https://code.sololearn.com/cSqGdcRau5rW/?ref=app Where i made mistake ? Or is it not possible to implement same interface with multiple classes ? Please explain :)
3 odpowiedzi
+ 1
When you implement a interface, you need to use all the methods mentioned in that interface in the class you implemented the interface into.
That is, if the number of methods in interface is x then the class implementing the interface should also have those x methods in it.
You have written 3 methods in your interface, but only used 1 method in a class and 2 method in other class. That's your error.
+ 2
Ohh! Got it:)
Able to run after using all methods in both class. Thank you Chetali Shah :)
+ 1
Yes you can but you have to override all its abstract methods in its each implementation classes