ExamVeda
Login
Home
Classes and Objects in C Sharp
?

What will be the output of the following C# code?
class maths
{
    public int length;
    public int breadth;
    public  maths(int x)
    {
        length = x + 1;
    }
    public maths(int x, int y)
    {
        length = x + 2;
    }
}
class Program
{
    static void Main(string[] args)
    {
        maths m = new maths(6);
        maths k = new maths(6, 2);
        Console.WriteLine(m.length);
        Console.WriteLine(k.length);
        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.