当前位置:网站首页>抽象类和接口的区别
抽象类和接口的区别
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
边栏推荐
- 【九阳神功】2016复旦大学应用统计真题+解析
- Differences and application scenarios between MySQL index clock B-tree, b+tree and hash indexes
- arduino+水位传感器+led显示+蜂鸣器报警
- 继承和多态(下)
- 13 power map
- View UI plus releases version 1.1.0, supports SSR, supports nuxt, and adds TS declaration files
- View UI Plus 发布 1.2.0 版本,新增 Image、Skeleton、Typography组件
- 4.30 dynamic memory allocation notes
- TYUT太原理工大学2022“mao gai”必背
- MySQL limit x, -1 doesn't work, -1 does not work, and an error is reported
猜你喜欢
Arduino+ds18b20 temperature sensor (buzzer alarm) +lcd1602 display (IIC drive)
String class
View UI plus released version 1.3.0, adding space and $imagepreview components
1.C语言初阶练习题(1)
Questions and answers of "basic experiment" in the first semester of the 22nd academic year of Xi'an University of Electronic Science and technology
13 power map
8.C语言——位操作符与位移操作符
魏牌:产品叫好声一片,但为何销量还是受挫
5.MSDN的下载和使用
Relational algebra of tyut Taiyuan University of technology 2022 database
随机推荐
(super detailed II) detailed visualization of onenet data, how to plot with intercepted data flow
Implement queue with stack
(超详细onenet TCP协议接入)arduino+esp8266-01s接入物联网平台,上传实时采集数据/TCP透传(以及lua脚本如何获取和编写)
MySQL Database Constraints
TYUT太原理工大学2022软工导论大题汇总
4.30动态内存分配笔记
string
【九阳神功】2020复旦大学应用统计真题+解析
MySQL limit x, -1 doesn't work, -1 does not work, and an error is reported
TYUT太原理工大学2022“mao gai”必背
1.C语言矩阵加减法
Mortal immortal cultivation pointer-1
Tyut Taiyuan University of technology 2022 introduction to software engineering summary
凡人修仙学指针-2
View UI plus released version 1.2.0 and added image, skeleton and typography components
Summary of multiple choice questions in the 2022 database of tyut Taiyuan University of Technology
魏牌:产品叫好声一片,但为何销量还是受挫
[中国近代史] 第六章测验
3. Number guessing game
TYUT太原理工大学往年数据库简述题