Difference between overloading and overriding?
Answers
Answered by
1
Heyyy mate...
Here is your answer
Overloading occurs when two or more methods in one class have the same method name but different parameters.
Overriding means having two methods with the same method name and parameters (i.e., method signature). One of the methods is in the parent class
Hope it helps!!!
ayushmaandey13:
Hi bhooma
Answered by
55
Overloading and overriding
Here is a difference between overloading and overriding:
◼️ Overloading ◼️
1) when two or more methods in one class have same method then, overloading occurs.
2) Diffrent kinds of parameters are used.
3) All classes and strings are different
◼️ Overriding ◼️
1) Overriding occurs when there is only one method
2) Only one parameter is used
3) All classed the and strings are used.
▪️ Output of Overloading numbers is like this:
➡️ Sum of two numbers: 0
➡️Sum of three numbers: 0
➡️Sum of four numbers: 0
➡️Sum of five numbers: 0
▪️ Output of overriding numbers will be like this:
➡️ Speed Limit is: 150
▪️ I have taken the example of add numbers in this.
Here is a difference between overloading and overriding:
◼️ Overloading ◼️
1) when two or more methods in one class have same method then, overloading occurs.
2) Diffrent kinds of parameters are used.
3) All classes and strings are different
◼️ Overriding ◼️
1) Overriding occurs when there is only one method
2) Only one parameter is used
3) All classed the and strings are used.
▪️ Output of Overloading numbers is like this:
➡️ Sum of two numbers: 0
➡️Sum of three numbers: 0
➡️Sum of four numbers: 0
➡️Sum of five numbers: 0
▪️ Output of overriding numbers will be like this:
➡️ Speed Limit is: 150
▪️ I have taken the example of add numbers in this.
Similar questions
Social Sciences,
6 months ago
Physics,
6 months ago
Science,
1 year ago
Math,
1 year ago
Physics,
1 year ago