C#面试题

当前位置: 面试问题网 > C#面试题 > What\'s the difference between an interface and abstract class? (接口与抽象类有什么区别)

What\'s the difference between an interface and abstract class? (接口与抽象类有什么区别)

C#面试题  手机阅读

  接口用于规范,抽象类用于共性。接口中只能声明方法,属性,事件,索引器。而抽象类中可以有方法的实现,也可以定义非静态的类变量。抽象类是类,所以只能被单继承,但是接口却可以一次实现多个。抽象类可以提供某些方法的部分实现,接口不可以.抽象类的实例是它的子类给出的。接口的实例是实现接口的类给出的。再抽象类中加入一个方法,那么它的子类就同时有了这个方法。而在接口中加入新的方法,那么实现它的类就要重新编写(这就是为什么说接口是一个类的规范了)。接口成员被定义为公共的,但抽象类的成员也可以是私有的、受保护的、内部的或受保护的内部成员(其中受保护的内部成员只能在应用程序的代码或派生类中访问)。此外接口不能包含字段、构造函数、析构函数、静态成员或常量。

【What\'s the difference between an interface and abstract class? (接口与抽象类有什么区别)】相关文章

1. What\'s the difference between an interface and abstract class? (接口与抽象类有什么区别)

2. What\'s the difference between Debug and Trace class? (Debug类与Trace类有什么区别)

3. 软件测试LoadRunner面试题:What is the difference between standard log and extended log?

4. What\'s the difference between deep copy and shallow copy? (深拷贝与浅拷贝有什么区别)

5. 软件测试LoadRunner面试题:What is the difference between Overlay graph and Correlate graph?

6. 软件测试LoadRunner面试题:What is correlation? Explain the difference between automatic correlation and manu

7. what is the difference between ext2 and ext3

8. 若通过ObjectOutputStream向一个文件中多次以追加方式写入object,为什么用ObjectInputStream读取这些object时会产生StreamCorruptedExcepti

9. abstract class和interface有什么区别?

10. abstract class和interface有什么区别

本文来源:https://www.mianshiwenti.com/a13028.html

点击展开全部

《What\'s the difference between an interface and abstract class? (接口与抽象类有什么区别)》

将本文的Word文档下载到电脑,方便收藏和打印

推荐程度:

进入下载页面
上一篇:Does C# support multiple inheritance? (C#支持多重继承吗) 下一篇:初级软件工程师面试题 Junior Software Engineer Interview

﹝What\'s the difference between an interface and abstract class? (接口与抽象类有什么区别)﹞相关内容

复制网址 收藏网址 分享到微信 分享到微博 分享到QQ

其它栏目

软件工程师面试题 软件测试面试题 网络管理员面试题 java面试题 .NET面试题 PHP面试题 C#面试题 C++面试题 Delphi面试题 Ruby面试题 Python面试题 Javascript面试题 android面试题 iOS面试题 jQuery面试题 Linux/Unix面试题 DBA面试题

也许您还喜欢