当前位置:网站首页>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
边栏推荐
- 拥抱开源指南
- Thinkphp5 behavior hook return result (data) example
- Why does acid food hurt teeth + early periodontitis
- 1331. Array sequence number conversion
- Design a system that supports millions of users
- 目标检测领域必看的6篇论文
- Using C language to compile student achievement management system (C language student achievement management system deleted)
- Top ten application development trends from 2022 to 2023
- How to effectively implement a rapid and reasonable safety evacuation system in hospitals
- Using C language to realize bidirectional linked list
猜你喜欢
![[极客大挑战 2019]BabySQL-1|SQL注入](/img/21/b5b4727178a585e610d743e92248f7.png)
[极客大挑战 2019]BabySQL-1|SQL注入

Today's sleep quality record 74 points

强缓存、协商缓存具体过程

数字孪生轨道交通:“智慧化”监控疏通城市运行痛点

Xiaoshuidi 2.0 website navigation network template

WPF layout controls are scaled up and down with the window, which is suitable for multi-resolution full screen filling applications

擦黑板特效表白H5源码+非常浪漫/附BGM

Techniques for visualizing large time series.

A hundred flowers bloom in data analysis engines. Why invest heavily in Clickhouse?

Introduction to the usage of SAP ui5 image display control avatar trial version
随机推荐
CVPR2021 行人重识别/Person Re-identification 论文+开源代码汇总
目标检测领域必看的6篇论文
【MySQL】Got an error reading communication packets
async await如何实现并发
The fifth generation verification code of "cloud centered, insensitive and extremely fast" is coming heavily
Leecode8 string conversion integer (ATOI)
R language uses dplyr package group_ By function and summarize function calculate the mean value of all covariates involved in the analysis based on grouped variables (difference in means of covariate
使用c语言实现双向链表
Function of interface test
Ripro9.0 revised and upgraded version +wp two beautification packages + rare plug-ins
Minikube initial experience environment construction
LabVIEW AI视觉工具包(非NI Vision)下载与安装教程
什么是WordPress
Who's the big God help? Let's see how Oracle number type parsing works. Struct{scale=15, Val
Guys, ask me, this can't be checkpoint, because there is a JDBC task whose task status is finished,
Unity鼠标带动物体运动的三种方法
301. Delete invalid brackets
Techniques for visualizing large time series.
B2 sub theme / blog b2child sub theme / open source code
Google Earth engine - use geetool to download single scene images in batches and retrieve NDSI results with Landsat 8