[Solved] Hello, can you tell me what is the difference between '' extends'' and "implements"in Java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 11

[Solved] Hello, can you tell me what is the difference between '' extends'' and "implements"in Java?

25th Aug 2019, 12:01 PM
Mantafounis Panagiotis
Mantafounis Panagiotis - avatar
14 Answers
+ 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.
25th Aug 2019, 1:21 PM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar
+ 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.
25th Aug 2019, 5:21 PM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar
+ 13
Idea is great but suppose i want different operations with both method ?
25th Aug 2019, 5:29 PM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar
+ 13
😂😁
25th Aug 2019, 5:39 PM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar
+ 8
Ohh thanks guys!! 🤣
25th Aug 2019, 1:29 PM
Mantafounis Panagiotis
Mantafounis Panagiotis - avatar
+ 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.)
25th Aug 2019, 12:45 PM
Seb TheS
Seb TheS - avatar
+ 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?
25th Aug 2019, 4:20 PM
Seb TheS
Seb TheS - avatar
+ 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.
25th Aug 2019, 12:48 PM
Seb TheS
Seb TheS - avatar
+ 3
Alpha5and5 #SCREW YOU CHEMISTRY Can you really "inherit" members from an interface? Isn't implemented interface just a rule for a class?
25th Aug 2019, 3:01 PM
Seb TheS
Seb TheS - avatar
+ 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 =)
25th Aug 2019, 8:53 PM
Ахан
Ахан - avatar
+ 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".
26th Aug 2019, 7:42 AM
Krishnanshu Dey
Krishnanshu Dey - avatar
+ 2
Thank you for the answer so now i know it
25th Aug 2019, 3:12 PM
Anthonius Wu
Anthonius Wu - avatar
+ 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
26th Aug 2019, 10:13 AM
Amoko Ivan
Amoko Ivan - avatar
+ 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
26th Aug 2019, 1:06 PM
Amir01
Amir01 - avatar