What is an Interface

社会主义新天地 提交于 2019-12-02 21:46:11

问题


With reference to UML diagrams, what is an interface? and can someone explain in more simpler words. I cant understand anything from googling it.


回答1:


An interface is like a template design for a class that contains no data or implemetnation; only definitions for methods, properties etc. These are abstract and cannot be instantiated but can be inherited from at which point all specified methods etc must be implemented by the concrete class inheriting the interface.




回答2:


An interface is a design item describing a behaviour. Classes implementing the interface will/must behave according to its definition. Interfaces are used to promote loose coupling and the base of many IoC patterns (Inversion of Control)




回答3:


A Interface is just a description of a class nothing concrete.

You use it to create a new class "with the same description" without knowing the concrete implementation.




回答4:


In one word: it's a contract. Every class that implements this contract (interface) will have to implement the methods defined on it.



来源:https://stackoverflow.com/questions/5742022/what-is-an-interface

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!