当前位置:网站首页>The difference between overloading and rewriting
The difference between overloading and rewriting
2022-07-06 13:39:00 【Wake up duck, did you program today?】
First , This question is often asked in interviews , But there is nothing between the two
heavy load :
Occurs in the same class , Method name must be the same , Different reference types , The number is different. , Different order , Method return value and decoration can be different , Occurs at compile time .
rewrite :
Occurs in a parent-child class , Method name , The parameter list can be different , The return value range is less than or equal to the parent class , A subclass cannot throw more exceptions than its parent class , The subclass access modifier range is greater than or equal to the parent class ; If the parent method access modifier is private, Then the subclass cannot override the method
The following situation is also wrong , Will report a mistake :
// The following compilation will report errors
public int add(int a,int b)
public String add(int a,int b)
The above is my understanding of the difference between rewriting and overloading , If some friends have a better understanding , You can leave a message in the comment area !!!
边栏推荐
- Solution: warning:tensorflow:gradients do not exist for variables ['deny_1/kernel:0', 'deny_1/bias:0',
- Quickly generate illustrations
- 5.函数递归练习
- 13 power map
- 5.MSDN的下载和使用
- Voir ui plus version 1.3.1 pour améliorer l'expérience Typescript
- 【九阳神功】2019复旦大学应用统计真题+解析
- 2.初识C语言(2)
- Redis cache obsolescence strategy
- [the Nine Yang Manual] 2022 Fudan University Applied Statistics real problem + analysis
猜你喜欢
2.C语言矩阵乘法
MPLS experiment
C language Getting Started Guide
这次,彻底搞清楚MySQL索引
6. Function recursion
透彻理解LRU算法——详解力扣146题及Redis中LRU缓存淘汰
3.输入和输出函数(printf、scanf、getchar和putchar)
(super detailed II) detailed visualization of onenet data, how to plot with intercepted data flow
甲、乙机之间采用方式 1 双向串行通信,具体要求如下: (1)甲机的 k1 按键可通过串行口控制乙机的 LEDI 点亮、LED2 灭,甲机的 k2 按键控制 乙机的 LED1
9. Pointer (upper)
随机推荐
Thoroughly understand LRU algorithm - explain 146 questions in detail and eliminate LRU cache in redis
There is always one of the eight computer operations that you can't learn programming
Tyut Taiyuan University of technology 2022 "Mao Gai" must be recited
[hand tearing code] single case mode and producer / consumer mode
Application architecture of large live broadcast platform
[au cours de l'entrevue] - Comment expliquer le mécanisme de transmission fiable de TCP
抽象类和接口的区别
3. C language uses algebraic cofactor to calculate determinant
vector
六种集合的遍历方式总结(List Set Map Queue Deque Stack)
C语言入门指南
重载和重写的区别
[中国近代史] 第九章测验
(超详细onenet TCP协议接入)arduino+esp8266-01s接入物联网平台,上传实时采集数据/TCP透传(以及lua脚本如何获取和编写)
受检异常和非受检异常的区别和理解
View UI plus released version 1.2.0 and added image, skeleton and typography components
【九阳神功】2017复旦大学应用统计真题+解析
【毕业季·进击的技术er】再见了,我的学生时代
[during the interview] - how can I explain the mechanism of TCP to achieve reliable transmission
4.二分查找