Examveda

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();
    }
}

A. 8, 8

B. 0, 2

C. 8, 10

D. 7, 8

Answer: Option D


Join The Discussion

Related Questions on Classes and Objects in C Sharp