当前位置:网站首页>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 !!!
边栏推荐
- [the Nine Yang Manual] 2021 Fudan University Applied Statistics real problem + analysis
- Thoroughly understand LRU algorithm - explain 146 questions in detail and eliminate LRU cache in redis
- 5月14日杂谈
- 20220211-CTF-MISC-006-pure_ Color (use of stegsolve tool) -007 Aesop_ Secret (AES decryption)
- 仿牛客技术博客项目常见问题及解答(二)
- C language Getting Started Guide
- [the Nine Yang Manual] 2020 Fudan University Applied Statistics real problem + analysis
- [hand tearing code] single case mode and producer / consumer mode
- Quickly generate illustrations
- 2. C language matrix multiplication
猜你喜欢
![[during the interview] - how can I explain the mechanism of TCP to achieve reliable transmission](/img/d6/109042b77de2f3cfbf866b24e89a45.png)
[during the interview] - how can I explain the mechanism of TCP to achieve reliable transmission

7.数组、指针和数组的关系

C language Getting Started Guide

8.C语言——位操作符与位移操作符

3.C语言用代数余子式计算行列式

C language to achieve mine sweeping game (full version)

2.初识C语言(2)

西安电子科技大学22学年上学期《基础实验》试题及答案

C语言入门指南

FAQs and answers to the imitation Niuke technology blog project (III)
随机推荐
Quickly generate illustrations
1. C language matrix addition and subtraction method
自定义RPC项目——常见问题及详解(注册中心)
MySQL lock summary (comprehensive and concise + graphic explanation)
MPLS experiment
Implement queue with stack
Redis的两种持久化机制RDB和AOF的原理和优缺点
3.猜数字游戏
Thoroughly understand LRU algorithm - explain 146 questions in detail and eliminate LRU cache in redis
View UI Plus 发布 1.3.1 版本,增强 TypeScript 使用体验
FAQs and answers to the imitation Niuke technology blog project (III)
学编程的八大电脑操作,总有一款你不会
9. Pointer (upper)
2.C语言矩阵乘法
C语言入门指南
为什么要使用Redis
[modern Chinese history] Chapter 6 test
Voir ui plus version 1.3.1 pour améliorer l'expérience Typescript
arduino+水位传感器+led显示+蜂鸣器报警
Aurora system model of learning database