当前位置:网站首页>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 !!!
边栏推荐
- 优先队列PriorityQueue (大根堆/小根堆/TopK问题)
- 六种集合的遍历方式总结(List Set Map Queue Deque Stack)
- Solution: warning:tensorflow:gradients do not exist for variables ['deny_1/kernel:0', 'deny_1/bias:0',
- C language to achieve mine sweeping game (full version)
- [面試時]——我如何講清楚TCP實現可靠傳輸的機制
- 5月27日杂谈
- 5. Download and use of MSDN
- View UI Plus 發布 1.3.1 版本,增强 TypeScript 使用體驗
- 6.函数的递归
- 杂谈0516
猜你喜欢
编写程序,模拟现实生活中的交通信号灯。
Quickly generate illustrations
关于双亲委派机制和类加载的过程
7.数组、指针和数组的关系
5. Function recursion exercise
View UI plus released version 1.2.0 and added image, skeleton and typography components
MySQL事务及实现原理全面总结,再也不用担心面试
A comprehensive summary of MySQL transactions and implementation principles, and no longer have to worry about interviews
Arduino+ water level sensor +led display + buzzer alarm
FAQs and answers to the imitation Niuke technology blog project (I)
随机推荐
【九阳神功】2019复旦大学应用统计真题+解析
4.二分查找
View UI Plus 发布 1.1.0 版本,支持 SSR、支持 Nuxt、增加 TS 声明文件
Arduino+ds18b20 temperature sensor (buzzer alarm) +lcd1602 display (IIC drive)
Mortal immortal cultivation pointer-1
MySQL事务及实现原理全面总结,再也不用担心面试
FAQs and answers to the imitation Niuke technology blog project (III)
一段用蜂鸣器编的音乐(成都)
Leetcode. 3. Longest substring without repeated characters - more than 100% solution
[中国近代史] 第九章测验
(super detailed II) detailed visualization of onenet data, how to plot with intercepted data flow
仿牛客技术博客项目常见问题及解答(三)
hashCode()与equals()之间的关系
[modern Chinese history] Chapter 6 test
2. Preliminary exercises of C language (2)
魏牌:产品叫好声一片,但为何销量还是受挫
The latest tank battle 2022 - full development notes-3
最新坦克大战2022-全程开发笔记-1
View UI Plus 发布 1.2.0 版本,新增 Image、Skeleton、Typography组件
Smart classroom solution and mobile teaching concept description