What are method overloading and method overriding in OOPs programming?
What are method overloading and method overriding in OOPs programming?
Hi, my self Ravi Vishwakarma. I have completed my studies at SPICBB Varanasi. now I completed MCA with 76% form Veer Bahadur Singh Purvanchal University Jaunpur.
SWE @ MindStick | Software Engineer | Web Developer | .Net Developer | Web Developer | Backend Engineer | .NET Core Developer
Ashutosh Kumar Verma
26-Aug-2021Overloading: Overloading of methods in a class specify that the name of methods are same but there parameter will be different which is passed in that methods. In other word there are two or more methods are available in class with same name but all methods have different parameters(different- sequence, type, number of parameters). It is automatically find suitable methods which type value passes in constructor of its class when create instance.
exp-
Output- Your name is Ashutosh
Your name is 24
your name is Ashutosh and your age is 24
Overriding: In C#, overriding of methods is just like overloading of methods in program but in case of overring there all methods with same name is created in different class with same parameter. Or in method overriding method name is same and parameters are also same of all methods (same- sequence, types, number of parameters) but all methods are created in different class.
Exp-
Output- Name: Examp Id: 1
Name: Exp Id: 2
Name: Mark Id: 3