C# Programming - Constructors - Discussion

Discussion Forum : Constructors - General Questions (Q.No. 2)
2.
Which of the following statements is correct about the C#.NET code snippet given below?
namespace IndiabixConsoleApplication
{ 
    class Sample
    { 
        public int func()
        {
            return 1;
        } 
        public Single func()
        { 
            return 2.4f ;
        } 
    } 
    class Program
    { 
        static void Main(string[ ] args)
        {
            Sample s1 = new Sample(); 
            int i;
            i = s1.func(); 
            Single j; 
            j = s1.func(); 
        } 
    } 
}
func() is a valid overloaded function.
Overloading works only in case of subroutines and not in case of functions.
func() cannot be considered overloaded because: return value cannot be used to distinguish between two overloaded functions.
The call to i = s1.func() will assign 1 to i.
The call j = s1.func() will assign 2.4 to j.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
15 comments Page 2 of 2.

Qyam uddin said:   1 decade ago
Signature should include following:

No of parameter.
Type of parameter.
Order of parameter.

Rajeev said:   1 decade ago
Because in method overloading parameters.

Should be different, not return type.

Sorna ranjani said:   1 decade ago
Functions are declared and they are not defined. So func is not overloaded.

Gowtham said:   1 decade ago
I think functions can be overloaded with the type and number of arguments.

Ammu said:   1 decade ago
@rajiv well said


Post your comments here:

Your comments will be displayed after verification.