Csharp.Net output type question

Q.  Trace the output
namespace A
{
    class MyClass
    {
        public void fun()
        {
            Console.WriteLine("C # is fun");
        }
    }
    namespace B
    {
        class MyClass
        {
            public void fun()
            {
                Console.WriteLine("C # is interesting");
            }
        }
    }
}
Consider the above code what will be the output of following program
class Program
    {
        static void Main(string[] args)
        {

            A.MyClass obj = new A.MyClass();
            obj.fun();
        }

    }

- Published on 31 Aug 15

a. C # is interesting
b. C # is fun
c. cmpile time error
d. None of the above

ANSWER: C # is fun
 

    Discussion

  • Nihal   -Posted on 19 Oct 15
    For example, All the classes for working a Microsoft SQL Server database are located in the System.Data.SqlClient namespace.
    In the above example, there is nested namespace and the obj of code
    A.MyClass obj = new A.MyClass();
    obj.fun();
    will acccess all the member of MyClass that is available in namespace A. So the answer will be C # is fun.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)