Examveda

What will be the output of the following C# code?
class math
{
    public int a,b;
    public math(int i,  int j)
    {
        a = i;
        b = j;
    }
    public  void sum(math m)
    {
        m.a *= 2;
        m.b += 2;
    }
}    
class Program
{
    static void Main(string[] args)
    {
        math t = new math(20,  10);
        t.sum(t);
        Console.WriteLine(t.a + "  " + t.b);   
        Console.ReadLine();
    }
}

A. 10, 20

B. 20, 10

C. 40, 12

D. 5, 40

Answer: Option C


Join The Discussion

Related Questions on Arrays and Strings in C Sharp