+ 11
[Solved] Hello, can you tell me what is the difference between '' extends'' and "implements"in Java?
20 odpowiedzi
+ 13
In simple words
extends mens you catch up your parent class method and veriables in child class . For instance, you can use your father's mobile phone.
Implementation mens (define) method that are delcare in interface.
+ 13
Alpha5and5 #SCREW YOU CHEMISTRY you are right with the help of interface you can achive multiple inheritance But Still You Can't Survive the Diamond Problem. For instance if you have same method in the both interface (I, j) and you implemented both interface in a same class than tell me which interface method will be called.
+ 13
Idea is great but suppose i want different operations with both method ?
+ 13
😂😁
+ 8
Ohh thanks guys!! 🤣
+ 4
Extends is used to extend a class with members of another class. It offers the class some class members from another class in case the current class needs them.
Implements is used to give interface information to a class. I'm not sure where interfaces are really used.
Simply use:
implements for interfaces
extends for classes
(I deleted my previous message due conflict.)
+ 4
Alpha5and5 #SCREW YOU CHEMISTRY Does it really "inherit" their content?
Do implemented interfaces have any other effects than just raising an error when the implemented interface members aren't defined?
+ 3
I think interfaces are used just to tell which methods a class is supposed have, but does not offer any class members to the class.
+ 3
Alpha5and5 #SCREW YOU CHEMISTRY
Can you really "inherit" members from an interface?
Isn't implemented interface just a rule for a class?
+ 3
Extends for class and implements for interface, example :
interface Iq {
// some code
}
class myIQ implements Iq
class Base {}
class Drived extends Base {}
I think I helped =)
+ 3
In simple word
If a child class inherit parent class then we use "extends"
Other side,
When one class inherit interface then we usually use "inplements".
And
If one interface inherit another interface we use "extends".
+ 2
Thank you for the answer so now i know it
+ 2
'extends' is used when a class (sub class) is inheriting properties of another class (superclass)
'implements' is used when a class is making use of a defined interface
+ 1
Class --(extends)--> Class
Interface --(extends)--> Interface
Class --(implements)--> Interface
I think this answer will help you!
https://stackoverflow.com/questions/10839131/implements-vs-extends-when-to-use-whats-the-difference