ExamVeda
Login
Home
Classes and Objects in C Sharp
?

What will be the output of the following C# code?
class overload
{
    public int x;
    int y;
    public int add(int a)
    {
        x = a + 1;
        return x;
    }
    public int add(int a, int b)
    {
        x = a + 2;
        return x;
    }
}    
class Program
{
    static void Main(string[] args)
    {
        overload obj = new overload();
        overload obj1 = new overload();
        int a = 0;
        obj.add(6);
        obj1.add(6, 2);
        Console.WriteLine(obj.x);
        Console.WriteLine(obj1.x);
        Console.ReadLine();
    }
}

Answer & Solution
Correct Answer: Option D
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.