i have 2 functions, int add(int a,int b);
double add(int a,int b); does this code implement
overloading? if not what will be the error?

Answers were Sorted based on User's Feedback



i have 2 functions, int add(int a,int b); double add(int a,int b); does this code implement over..

Answer / dhakir hussain

it will throw an error because the function overloading is
acheived by
1) changing the number of parameters
2) changing the order of parameters of different datatypes

we can't acheive function overloading by changing the
return type

Is This Answer Correct ?    26 Yes 0 No

i have 2 functions, int add(int a,int b); double add(int a,int b); does this code implement over..

Answer / manoj gharat

it will throw compile error because of same parameter's
data type in second overloaded function.

Is This Answer Correct ?    5 Yes 0 No

i have 2 functions, int add(int a,int b); double add(int a,int b); does this code implement over..

Answer / ar prabhakaran

C#: CIL supports overloading by return type

C# and most other languages that allow method overloading do
not allow overloading by return type. What this means is
that methods can be overloading only if they differ by
parameters. So the following code will not compile as the
methods differ only by return type

class Employee

{

//...

}

class Program

{

static int Func(Employee emp) {

return emp.Id;

}

static string Func(Employee emp) {

return emp.Name;

}

}

Is This Answer Correct ?    3 Yes 5 No

i have 2 functions, int add(int a,int b); double add(int a,int b); does this code implement over..

Answer / suren

That will throw an error coz in the second function the
return type is double and result will be in double. to
rectify it we need to convert the second function result as
double, then the code executes correctly.

Is This Answer Correct ?    1 Yes 10 No

Post New Answer

More Dot Net General Interview Questions

How do I spawn a thread?

0 Answers  


What is strong-typing versus weak-typing? Which is preferred?

0 Answers  


I was working for software company frm 2005 to 2009. I left job due to recession.I was jobless till dec 09 then i got job in bpo and i am not knowing what to do as my professional experience is with software.give me any suggestion.

0 Answers  


What are use of Cloud computing....?

1 Answers   CTS,


What is the difference between user control an custom control? Advantages/disadvantages?

0 Answers  






Explain the procedure to add assemly to gac to make it shared one?

0 Answers  


Explain me what is the .net framework and how does it work?

0 Answers  


What is assemblies in .net?

0 Answers  


How to prepare parametrized (with more than one parameters) crystal report.pls tell me the code procedure, if any body can?

0 Answers  


When should I use .net core?

0 Answers  


How anonymous method is different from a lambda expression?

0 Answers  


How to store and retrieve images in SQL server database through VB.NET?

1 Answers  


Categories