How would you apply an interface in a real world scenario? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 7

How would you apply an interface in a real world scenario?

I understand the concept and mechanics of an interface, but how would one use an interface practically?

15th Jun 2017, 4:36 AM
Russel Braum
Russel Braum - avatar
5 ответов
+ 6
What I'm asking is, how does an interface benefit a project as opposed to an abstract class for example?
15th Jun 2017, 5:29 AM
Russel Braum
Russel Braum - avatar
+ 5
so the attributes and methods are defined in an interface and implemented by a class? Or can they be implemented anywhere?
15th Jun 2017, 5:35 AM
Russel Braum
Russel Braum - avatar
+ 4
oh now i understand the two are not really to be compared with abstract prevents instanciation of the class might be good for inheritance where you don't want to instantiate the superclass interface allows different entities, besides inheriting, to have extra attributes / methods
15th Jun 2017, 5:32 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 4
interfaces meth can be used in a class
15th Jun 2017, 5:37 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 3
can you please elaborate?
15th Jun 2017, 5:11 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar