当前位置:网站首页>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
边栏推荐
- Database advanced learning notes - system package
- Object to object mapping -automapper
- Guys, ask me, this can't be checkpoint, because there is a JDBC task whose task status is finished,
- [pyGame practice] when the end of the world comes, how long can you live in a cruel survival game that really starts from scratch?
- Solutions to slow start of MATLAB
- How to effectively implement a rapid and reasonable safety evacuation system in hospitals
- AlexNet—论文分析及复现
- MySQL离线同步到odps的时候 可以配置动态分区吗
- [general database integrated development environment] Shanghai daoning provides you with Aqua Data Studio downloads, tutorials, and trials
- AlexNet—论文分析及复现
猜你喜欢

Zotero document manager and its use posture (updated from time to time)

Refresh your understanding of redis cluster

Open source huizhichuang future | 2022 open atom global open source summit openatom openeuler sub forum was successfully held

Will PFP be the future of digital collections?

Cvpr2020 best paper: unsupervised learning of symmetric deformable 3D objects

Top ten application development trends from 2022 to 2023

Introduction to web security RADIUS protocol application

Function of interface test

Today's sleep quality record 74 points

Boutique scheme | Haitai Fangyuan full stack data security management scheme sets a "security lock" for data
随机推荐
强缓存、协商缓存具体过程
Today's sleep quality record 74 points
一种比读写锁更快的锁,还不赶紧认识一下
Database advanced learning notes -- object type
Thinkphp5行为钩子Hook返回结果(数据)示例
Thinkphp5 behavior hook return result (data) example
【MySQL】Got an error reading communication packets
Summary of common RSA related problems in CTF: basic RSA encryption and decryption
Byte side: how to realize reliable transmission with UDP?
Google Earth engine - use geetool to download single scene images in batches and retrieve NDSI results with Landsat 8
Object stream of i/o operation (serialization and deserialization)
Advanced database technology learning notes 1 -- Oracle deployment and pl/sql overview
Five Ali technical experts have been offered. How many interview questions can you answer
Postgres overview
How to use JWT for authentication and authorization
js代码如何被浏览器引擎编译执行的?
[pyGame practice] the super interesting bubble game is coming - may you be childlike and always happy and simple~
Who's the big God help? Let's see how Oracle number type parsing works. Struct{scale=15, Val
Will PFP be the future of digital collections?
R language uses oneway The test function performs one-way ANOVA