当前位置:网站首页>抽象类和接口的区别
抽象类和接口的区别
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
边栏推荐
- Relational algebra of tyut Taiyuan University of technology 2022 database
- Change vs theme and set background picture
- [Topic terminator]
- 7. Relationship between array, pointer and array
- 5.MSDN的下载和使用
- Comparison between FileInputStream and bufferedinputstream
- Summary of multiple choice questions in the 2022 database of tyut Taiyuan University of Technology
- A brief introduction to the database of tyut Taiyuan University of technology in previous years
- 8. C language - bit operator and displacement operator
- 5. Function recursion exercise
猜你喜欢

(super detailed II) detailed visualization of onenet data, how to plot with intercepted data flow

3. Number guessing game

Tyut Taiyuan University of technology 2022 introduction to software engineering summary

Tyut Taiyuan University of technology 2022 "Mao Gai" must be recited

Common method signatures and meanings of Iterable, collection and list

TYUT太原理工大学2022数据库题库选择题总结

What are the advantages of using SQL in Excel VBA

5.函数递归练习

Quickly generate illustrations

2-year experience summary, tell you how to do a good job in project management
随机推荐
TYUT太原理工大学2022数据库大题之E-R图转关系模式
【九阳神功】2017复旦大学应用统计真题+解析
C语言实现扫雷游戏(完整版)
西安电子科技大学22学年上学期《基础实验》试题及答案
View UI plus released version 1.3.0, adding space and $imagepreview components
Tyut Taiyuan University of technology 2022 introduction to software engineering
2. Preliminary exercises of C language (2)
Redis cache obsolescence strategy
First acquaintance with C language (Part 1)
3.猜数字游戏
View UI Plus 发布 1.1.0 版本,支持 SSR、支持 Nuxt、增加 TS 声明文件
TYUT太原理工大学2022数据库大题之概念模型设计
MySQL Database Constraints
初识C语言(上)
Quickly generate illustrations
View UI Plus 发布 1.3.0 版本,新增 Space、$ImagePreview 组件
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
View UI plus released version 1.2.0 and added image, skeleton and typography components
9. Pointer (upper)
1.C语言初阶练习题(1)