当前位置:网站首页>Interfaces and abstract classes
Interfaces and abstract classes
2022-07-28 11:47:00 【hanyc..】
The same thing :
1、 Interfaces and abstract classes cannot be instantiated
2、 Can contain abstract methods
3、 Are at the top of the inheritance tree
Difference :
1、 Multiple implementation 、 Single implementation
2、 Only static constants can be defined in an interface (public static final), Ordinary member variables can be defined in abstract classes , You can also define static constants
3、 There are no constructors in the interface , Abstract classes can contain constructors , But the constructor of abstract classes is not used to create objects , Instead, let its subclass call these constructors to complete the initialization of the abstract class
4、 stay java8 Before , The interface contains only abstract methods , There is no way to achieve , Only the definition of method (java8 It is allowed to add static methods and default methods in the interface ); Abstract classes can contain ordinary methods , It can also contain abstract methods
5、java8 Before , The methods in the interface are automatically public; The methods in an abstract class can be public、 default 、protected etc.
6、 The use of interfaces is more oriented towards certain functions , Abstract classes emphasize ownership , Such as A is a B
7、 If the implementation class implements an interface , Then it needs to implement all the abstract methods in this interface ; When subclasses inherit an abstract class , If it fails to implement all the abstract methods in the abstract class , So subclasses are also abstract classes , Still cannot be instantiated
边栏推荐
- What is the process of switching c read / write files from user mode to kernel mode?
- An example of the mandatory measures of Microsoft edge browser tracking prevention
- Introduction to web security RADIUS protocol application
- 从0开发一个自己的npm包
- Router firmware decryption idea
- PHP检测url网址链接是否正常可访问
- CVPR2020 best paper:对称可变形三维物体的无监督学习
- 一些多参数函数的具体作用
- Function of interface test
- 完整版H5社交聊天平台源码[完整数据库+完整文档教程]
猜你喜欢

LabVIEW AI视觉工具包(非NI Vision)下载与安装教程

强缓存、协商缓存具体过程
![Full version of H5 social chat platform source code [complete database + complete document tutorial]](/img/3f/03239c1b4d6906766348d545a4f234.png)
Full version of H5 social chat platform source code [complete database + complete document tutorial]

Excel shortcut keys (letters + numbers) Encyclopedia

一文看懂设备指纹如何防篡改、防劫持

可视化大型时间序列的技巧。

目标检测领域必看的6篇论文

Leecode8 string conversion integer (ATOI)

LabVIEW AI visual Toolkit (non Ni vision) download and installation tutorial

108. Introduction to the usage of SAP ui5 image display control Avatar
随机推荐
I/O实操之对象流(序列化与反序列化)
AlexNet—论文分析及复现
How to use JWT for authentication and authorization
[极客大挑战 2019]BabySQL-1|SQL注入
Introduction to the usage of SAP ui5 image display control avatar trial version
Thinkphp5 behavior hook return result (data) example
数字孪生轨道交通:“智慧化”监控疏通城市运行痛点
I want to ask you guys, if there is a master-slave switch when CDC collects mysql, is there any solution
STM32 drives st7701s chip (V ⅰ V0 mobile phone screen change price)
Guys, ask me, this can't be checkpoint, because there is a JDBC task whose task status is finished,
Cvpr2020 best paper: unsupervised learning of symmetric deformable 3D objects
Solutions to the disappearance of Jupiter, spyder, Anaconda prompt and navigator shortcut keys
Can dynamic partitions be configured when MySQL is offline synchronized to ODPs
[half understood] zero value copy
Flutter tutorial flutter navigator 2.0 with gorouter, use go_ Router package learn about the declarative routing mechanism in fluent (tutorial includes source code)
Iterative method for determinant (linear algebraic formula)
Techniques for visualizing large time series.
108. Introduction to the usage of SAP ui5 image display control Avatar
Service Workers让网站动态加载Webp图片
[pyGame practice] when the end of the world comes, how long can you live in a cruel survival game that really starts from scratch?