当前位置:网站首页>Inheritance and polymorphism
Inheritance and polymorphism
2022-07-23 11:57:00 【shuo277】
1. What is inheritance ? What is the role of inheritance ? How to write inheritance ?
Inherit : Is a mechanism for creating new classes from existing classes , The class obtained by inheritance is called subclass , Inherited classes are called parent classes .
effect : Simplified code
keyword :extends
2. polymorphic
polymorphic : It is the ability of the same behavior to have multiple different forms or forms .
The same object Cite different instances Get different results
Inheritance is a manifestation of polymorphism
super : Used to inherit parent methods call
Object The parent of all classes Superclass
Advantages of polymorphism
- 1. Eliminate coupling between types
- 2. Replaceability
- 3. Extensibility
- 4. Interface
- 5. flexibility
- 6. Simplicity
3. What is the difference between method overloading and method rewriting ?
Method overloading : The method name is the same , parameter list ( Number of parameters , Parameter data type ) Different ;
Method rewrite : Subclasses inherit the methods of their parents , And improve it , Become a subclass's own method , This practice is called method coverage , Also known as method rewriting .
difference : Overloading can occur in a class , It can also occur between subclasses and parents , And rewrite , Only subclasses can override parent methods
4.final What do keywords mean ? How to use... In code ?
final The final
Modifying variables Variable constant Do not modify
Modifier class cannot be inherited
Modifier cannot be overridden
Decorated objects cannot be referenced again
边栏推荐
猜你喜欢

UE4.24版本VR项目打包后,未出现手柄控制器

10. I/o input / output stream

查看真机APP里面沙盒文件

使用飞桨实现肺部 CT 扫描的 3D 图像分类

Mosaic the face part of the picture

Machine learning algorithm for large factory interview (5) recommendation system algorithm

Develop necessary idea use

数仓4.0笔记---用户行为数据生成

Development of digital collection system: enterprise layout meta universe digital collection

New BPMN file used by activiti workflow
随机推荐
Development of digital collection system: Baidu AI pays tribute to Air China
对.h5文件的迭代显示,h5py数据操作
MySQL存储引擎
Kubesphere haproxy+kept (I)
數倉4.0筆記——業務數據采集
九、实用类
Service服务
Websocket long connection
DBA命令
ninja介绍及使用
MySQL sorts by Chinese field initials
数仓4.0笔记——用户行为数据采集二
Unable to negotiate with port 51732: no matching host key type found. Their offer:
Mysql database
1.认识数据库
Data warehouse 4.0 notes - business data collection - sqoop
[hudi]hudi compilation and simple use of Hudi & spark and Hudi & Flink
求1~100之间不能被3整除的数之和
3. DQL (data query statement)
MySQL视图