Total Page Preview: 000000008404
Explain Difference between Method overriding and method overloading in OOPS in English and Hindi
Difference between method overriding and method overloading in English
Here's a tabular comparison between method overriding and method overloading in C#, along with examples:
Example of method overriding in C#:
In this example, the Animal class has a virtual method MakeSound() that is overridden in the Cat class with its own implementation. When the MakeSound() method is called on an instance of Cat, it calls the Cat class's implementation of MakeSound().
Example of method overloading in C#:
In this example, the Calculator class has two methods with the same name Add(), but different parameters - one takes two integers, and the other takes two doubles. When calling the Add() method with different inputs, the compiler selects the method with the most specific parameters that match the input.
Difference between method overriding and method overloading in Hindi
Method Overloading aur Method Overriding dono OOPS ka concept hai, lekin dono ka istemal bilkul alag-alag scenarios mein hota hai. Main dono ka antar tabular form mein explain kar raha hun, sath hi sath C# ke examples bhi provide karunga.
Method Overloading:
Method overloading ka matlab hota hai ek class mein do ya do se zyada methods ka naam same hote hue bhi alag-alag functionality perform karna. Method overloading compile time polymorphism ka example hai. Method overloading mein same method name ke saath multiple methods define kiye jate hain, par unke paas arguments ka types, order aur number different hote hain.
Tabular form mein method overloading ka antar:
C# example of Method Overloading:
Method Overriding:
Method Overriding ka matlab hota hai, derived class ke method mein base class ke method ko replace karna. Method Overriding run time polymorphism ka example hai. Derived class mein base class ke method ko replace karne ke liye, same method name, same return type, same parameter hote hain. Yeh derived class ko flexibility dete hain ki woh apni marzi ke hisab se base class ke method ko modify kar sake.
Tabular form mein method overriding ka antar:
C# example of Method Overriding:
Thank You
About Author
Brijesh Kumar
Database Developer
I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL
Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall
and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com