+10

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

20 Answers

New Answer

+12

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.

+11

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.

+11

Idea is great but suppose i want different operations with both method ?

+11

+7

+7

Yeah it inherit their content 😂😂😂😂

+5

Seb TheS you can do this public interface gender{} public interface intel{} public interface man extends gender,Intel{} Which I think is a "multiple inheritance"

+5

Sumit Programmer😎😎 What about inherit j to I with using extends keyword and implenting then. I just guess with little logic 😂😂

+5

Well then I don't have answer and I will curse java 😂😂

+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

Sumit Programmer😎😎 and Seb TheS gave a nice answer but there is also you can achieve multiple inheritance using interface which is not possible in classes which mean you can implement multiple interfaces but not classes.

+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".

+3

Amoko Ivan but you can make interface inherit using extends from multiple interfaces

+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