当前位置:网站首页>抽象类和接口的区别
抽象类和接口的区别
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
边栏推荐
- [中国近代史] 第六章测验
- 7. Relationship between array, pointer and array
- Questions and answers of "Fundamentals of RF circuits" in the first semester of the 22nd academic year of Xi'an University of Electronic Science and technology
- [中国近代史] 第九章测验
- TYUT太原理工大学2022数据库大题之E-R图转关系模式
- TYUT太原理工大学2022数据库大题之分解关系模式
- Alibaba cloud microservices (IV) service mesh overview and instance istio
- Aurora system model of learning database
- TYUT太原理工大学2022软工导论大题汇总
- 2-year experience summary, tell you how to do a good job in project management
猜你喜欢
C语言实现扫雷游戏(完整版)
(超详细二)onenet数据可视化详解,如何用截取数据流绘图
IPv6 experiment
MySQL 30000 word essence summary + 100 interview questions, hanging the interviewer is more than enough (Collection Series
Arduino+ds18b20 temperature sensor (buzzer alarm) +lcd1602 display (IIC drive)
抽象类和接口
9. Pointer (upper)
View UI plus released version 1.2.0 and added image, skeleton and typography components
3.C语言用代数余子式计算行列式
arduino+水位传感器+led显示+蜂鸣器报警
随机推荐
3.C语言用代数余子式计算行列式
【九阳神功】2022复旦大学应用统计真题+解析
【九阳神功】2019复旦大学应用统计真题+解析
2. C language matrix multiplication
Mortal immortal cultivation pointer-1
Counter attack of flour dregs: redis series 52 questions, 30000 words + 80 pictures in detail.
最新坦克大战2022-全程开发笔记-2
Common method signatures and meanings of Iterable, collection and list
8. C language - bit operator and displacement operator
六种集合的遍历方式总结(List Set Map Queue Deque Stack)
C语言入门指南
4.分支语句和循环语句
【九阳神功】2020复旦大学应用统计真题+解析
IPv6 experiment
Differences and application scenarios between MySQL index clock B-tree, b+tree and hash indexes
View UI plus released version 1.2.0 and added image, skeleton and typography components
Tyut Taiyuan University of technology 2022 introduction to software engineering examination question outline
167. Sum of two numbers II - input ordered array - Double pointers
arduino+水位传感器+led显示+蜂鸣器报警
Set container