Qus:    Explain about the method overloading.
Dec 09, 2020 12:42 2 Answers Views: 109 SHIVA

Public class Mycalcuation

{

Private int a;

Private int b;

Private int c;

Public int Add(int a,int b)

{

Return a+b;

}

Public int Add(int a,int b,int c)

{

Return a+b+c;

}

}

Static void Main()

{

MyCalculation objCalc= new MyCalculation();

ObjCalc.Add(2,3)

// It will call first method Add which has two argument

ObjCalc.Add(2,3,4)

// It will call Second method Add which has

three argument eventhough it has same name

}

Prev Next
Answers (2)
PARTH Dec 10, 2020 08:03
Answer:   Method overloading allows programmers to use multiple methods with the same name. The methods are differentiated based on their number and type of method arguments.

RAMU Dec 11, 2020 08:09
Answer:   Public class Mycalcuation
{
Private int a;
Private int b;
Private int c;
Public int Add(int a,int b)
{
Return a+b;
}
Public int Add(int a,int b,int c)
{
Return a+b+c;
}
}
Static void Main()
{
MyCalculation objCalc= new MyCalculation();
ObjCalc.Add(2,3)
// It will call first method Add which has two argument
ObjCalc.Add(2,3,4)
// It will call Second method Add which has
three argument eventhough it has same name
}

Post Your Answer
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect