Exercise: Constructors

Questions for: Constructors

Which of the following statements is correct about the C#.NET code snippet given below?
namespace ExamAdept
{ 
    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(); 
        } 
    } 
}
A:
func() is a valid overloaded function.
B:
Overloading works only in case of subroutines and not in case of functions.
C:
func() cannot be considered overloaded because: return value cannot be used to distinguish between two overloaded functions.
D:
The call to i = s1.func() will assign 1 to i.
Answer: C
No answer description is available. Let's discuss.
Ad Slot (Above Pagination)
Quiz