当前位置:网站首页>抽象类和接口的区别
抽象类和接口的区别
2022-07-06 09:20:00 【快醒醒鸭今天你编程了吗?】
首先咱们来看抽象类,什么是抽象类?
1、抽象类里不一定有抽象方法,抽象类必须要有关键字abstract来修饰
2、如果一个类包含抽象方法,那么这个类一定是抽象类
3、抽象类不能用final修饰代表,因为抽象类是被用于继承的,但是final修饰代表不可修改,不可继承
接口和抽象类的区别?
1、一个子类只能继承一个抽象类,但是可以实现多个接口
2、抽象类有构造方法,接口没有构造方法
3、抽象类可以有普通成员变量,接口中不能有
4、抽象类和接口都可以有静态成员变量,但是抽象类中成员变量可以是任意类型,接口只能是public static final(默认)
5、抽象类中不一定要有抽象方法,但是接口中的方法必须都是抽象的
6、抽象类中可以有静态方法,接口中不能有静态方法
7、抽象类中的方法可以是public、protected,接口中的方法只能是public
边栏推荐
猜你喜欢
5. Function recursion exercise
C语言入门指南
Cloud native trend in 2022
1.C语言矩阵加减法
Data manipulation language (DML)
There is always one of the eight computer operations that you can't learn programming
Relational algebra of tyut Taiyuan University of technology 2022 database
System design learning (I) design pastebin com (or Bit.ly)
(超详细onenet TCP协议接入)arduino+esp8266-01s接入物联网平台,上传实时采集数据/TCP透传(以及lua脚本如何获取和编写)
Mortal immortal cultivation pointer-1
随机推荐
(超详细onenet TCP协议接入)arduino+esp8266-01s接入物联网平台,上传实时采集数据/TCP透传(以及lua脚本如何获取和编写)
MySQL 30000 word essence summary + 100 interview questions, hanging the interviewer is more than enough (Collection Series
Introduction and use of redis
What are the advantages of using SQL in Excel VBA
Atomic and nonatomic
E-R graph to relational model of the 2022 database of tyut Taiyuan University of Technology
分支语句和循环语句
12 excel charts and arrays
TYUT太原理工大学2022数据库题库选择题总结
Branch and loop statements
Alibaba cloud microservices (IV) service mesh overview and instance istio
8. C language - bit operator and displacement operator
魏牌:产品叫好声一片,但为何销量还是受挫
The latest tank battle 2022 full development notes-1
Relational algebra of tyut Taiyuan University of technology 2022 database
System design learning (III) design Amazon's sales rank by category feature
13 power map
Application architecture of large live broadcast platform
Questions and answers of "signal and system" in the first semester of the 22nd academic year of Xi'an University of Electronic Science and technology
Alibaba cloud microservices (III) sentinel open source flow control fuse degradation component