当前位置:网站首页>Abstract methods and abstract classes
Abstract methods and abstract classes
2022-06-12 22:56:00 【I met you too】
Abstract methods and abstract classes
Abstract method : That is to add abstract keyword , Then remove the braces , End of semicolon .
abstract class : The class of the abstract method is the abstract class . stay class Write before abstract that will do . Abstract class cannot create object , If the build fails , Only objects with non Abstract subclasses can be created .
There can be construction methods in abstract classes , Is used by subclasses to create objects , Initializes the . Subclass construction method , There is a default super(); You need to access the constructor of the parent class
Abstract classes don't necessarily contain abstract methods , But a class with an abstract method must be an abstract class .
Subclasses of abstract classes must override all abstract methods in the abstract parent class , Otherwise, the compilation fails and an error is reported , Unless the subclass is also an abstract class .
How to use abstract classes and abstract methods :
1、 You can't create... Directly new An abstract class object .
2、 You must inherit the abstract parent class with a subclass .
3、 Subclasses must override all abstract methods in the overriding Abstract parent class .
When overriding , Subclasses remove the of abstract methods abstract keyword , Add braces to write the content .
4、 Create subclass objects for use .
边栏推荐
- The development trend of digital collections!
- 【Web技术】1348- 聊聊水印实现的几种方式
- DETR(Detection with Transformers) 学习笔记
- Qt Quick 3D学习:鼠标拾取物体
- China's alternative sports equipment market trend report, technology dynamic innovation and market forecast
- Pytorch中的梯度累加【在实验时,由于GPU显存限制,遇到batch_size不能再增大的情况。为解决该问题,使用梯度累加方法】
- Hostvars in ansible
- VIM use the lower right 4 keys
- Insight into China's smart medical industry in 2022
- 80 lines of code to realize simple rxjs
猜你喜欢

iShot

Mysql concat_ws、concat函数使用

ShardingSphere-proxy-5.0.0部署之分表实现(一)

JVM foundation > G1 garbage collector

web3 原则和去中心化

ShardingSphere-proxy-5.0.0部署之分表实现(一)

The carrying capacity of L2 level ADAS increased by more than 60% year-on-year in January, and domestic suppliers "emerged"

模型过拟合-解决方案(二):Dropout

Photoshop:ps how to enlarge a picture without blurring

Insight into China's smart medical industry in 2022
随机推荐
Analysis report on the "fourteenth five year plan" and the latest development trend of China's medical information industry from 2022 to 2028
OpenCV源代码编译
3.5 setup and teardown of test classes
The development trend of digital collections!
(downloadable) Research Report on the development and utilization of government data (2021), a glimpse of the development of Government Office
【LeetCode】5. Longest Palindromic Substring
Several Tsinghua students I know have left
Inventory of CV neural network models from 2021 to 2022
Plusieurs camarades de classe de Tsinghua sont partis...
Is it safe to open an account in flush? How to open an account online to buy stocks
Module 8 operation
数字藏品的发展趋势!
度量学习(Metric Learning)【AMSoftmax、Arcface】
Hostvars in ansible
项目里面的traceID的设计
Lua conditional statement
Shardingsphere-proxy-5.0.0 deployment table implementation (I)
Research Report on water sports shoes industry - market status analysis and development prospect forecast
Gb28181 protocol -- alarm
China's elastic belt market trend report, technical dynamic innovation and market forecast