接口和抽象类有什么区别?
问题描述:
可能是最着名的软件开发人员面试问题之一。
Probably one of the most famous software developer job interview questions.
你的答案是什么?
编辑:我正在试图找出如何在现实生活中回答这个问题。请尝试像在实际面试中一样制定答案(完整,但不要太长,当然不要发布任何链接)。
I'm trying to find out how you would answer this in a real-life situation. Please try to formulate your answer as you would on a real job interview (be complete, but don't be too long, post no links of course).
答
接口只描述其方法的实际签名等。实现该接口的任何类必须提供显式实现。
An interface only describes the actual signature of its methods etc. Any class implementing that interface must then provide an explicit implementation.
抽象类可以包含其方法的部分实现等。
An abstract class can contain a partial implementation of its methods etc.