---
title: "What are method overloading and method overriding in OOPs programming?"  
description: "What are method overloading and method overriding in OOPs programming?"  
author: "Ravi Vishwakarma"  
published: 2021-08-23  
updated: 2021-08-23  
canonical: https://www.mindstick.com/forum/156703/what-are-method-overloading-and-method-overriding-in-oops-programming  
category: "c#"  
tags: ["c#", "java", "c++"]  
reading_time: 3 minutes  

---

# What are method overloading and method overriding in OOPs programming?

What are [method overloading](https://www.mindstick.com/forum/127/method-overloading) and [method overriding](https://www.mindstick.com/forum/53/method-overriding) in [OOPs programming](https://www.mindstick.com/forum/156693/how-many-types-of-classes-are-in-c-sharp-oops-programming)?

## Replies

### Reply by Ashutosh Kumar Verma

**Overloading:** 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-

```
class Demo
    {
        public void Test(string name)
        {
            Console.WriteLine('Your name is'+name);
        }
        public void Test(int age)
        {
            Console.WriteLine('your age is'+age);
        }
        public void Test(string name, int age)
        {
            Console.WriteLine('your name is '+name+' and your age is '+age);
        }
    }
    class OverloadingExp
    {
        static void Main(string[] arg)
        {
            Demo demo = new Demo();
            demo.Test('Ashutosh \n');
            demo.Test(24+'\n');
            demo.Test('Ashutosh',24);
        }
    }
```

**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](https://www.mindstick.com/forum/166/webservice-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-

```
 public class Examp
    {
       public void Task(string name, int id)
        {
            Console.WriteLine('Name:{0}',name +' Id: '+ id);
        }
    }
    public class Exp
    {
        public void Task(string name, int id)
        {
            Console.WriteLine('Name:{0}',name + 'Id: '+id);
        }
    }
    public class Mark
    {
        public void Task(string name, int id)
        {
            Console.WriteLine('Name:{0}',name + 'Id: '+ id);
        }
    }
    class OverridigExp
    {
        static void Main(string[] arg)
        {
            Examp exe = new Examp();
            exe.Task('Examp',001);
            Exp exp = new Exp();
            exp.Task('Exp ' ,002);
            Mark mark = new Mark();
            mark.Task('Mark ', 003);  }   }   
```

Output- Name: Examp Id: 1

Name: Exp Id: 2

Name: Mark Id: 3

\


---

Original Source: https://www.mindstick.com/forum/156703/what-are-method-overloading-and-method-overriding-in-oops-programming

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
