当前位置:网站首页>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 !!!
边栏推荐
- Leetcode. 3. Longest substring without repeated characters - more than 100% solution
- C语言入门指南
- 5. Download and use of MSDN
- Redis的两种持久化机制RDB和AOF的原理和优缺点
- 【九阳神功】2022复旦大学应用统计真题+解析
- Data manipulation language (DML)
- 【九阳神功】2016复旦大学应用统计真题+解析
- 受检异常和非受检异常的区别和理解
- [面試時]——我如何講清楚TCP實現可靠傳輸的機制
- MySQL limit x, -1 doesn't work, -1 does not work, and an error is reported
猜你喜欢
(ultra detailed onenet TCP protocol access) arduino+esp8266-01s access to the Internet of things platform, upload real-time data collection /tcp transparent transmission (and how to obtain and write L
View UI Plus 发布 1.2.0 版本,新增 Image、Skeleton、Typography组件
Change vs theme and set background picture
MySQL lock summary (comprehensive and concise + graphic explanation)
更改VS主题及设置背景图片
Arduino+ water level sensor +led display + buzzer alarm
Tyut Taiyuan University of technology 2022 "Mao Gai" must be recited
仿牛客技术博客项目常见问题及解答(二)
[hand tearing code] single case mode and producer / consumer mode
Data manipulation language (DML)
随机推荐
FAQs and answers to the imitation Niuke technology blog project (III)
IPv6 experiment
6.函数的递归
[the Nine Yang Manual] 2021 Fudan University Applied Statistics real problem + analysis
[the Nine Yang Manual] 2018 Fudan University Applied Statistics real problem + analysis
3. Number guessing game
[the Nine Yang Manual] 2020 Fudan University Applied Statistics real problem + analysis
arduino+水位传感器+led显示+蜂鸣器报警
[the Nine Yang Manual] 2016 Fudan University Applied Statistics real problem + analysis
Questions and answers of "basic experiment" in the first semester of the 22nd academic year of Xi'an University of Electronic Science and technology
List set map queue deque stack
JS interview questions (I)
Cloud native trend in 2022
[面試時]——我如何講清楚TCP實現可靠傳輸的機制
自定义RPC项目——常见问题及详解(注册中心)
使用Spacedesk实现局域网内任意设备作为电脑拓展屏
(ultra detailed onenet TCP protocol access) arduino+esp8266-01s access to the Internet of things platform, upload real-time data collection /tcp transparent transmission (and how to obtain and write L
hashCode()与equals()之间的关系
Summary of multiple choice questions in the 2022 database of tyut Taiyuan University of Technology
魏牌:产品叫好声一片,但为何销量还是受挫