adplus-dvertising
frame-decoration

Question

What will be the output of the following set of code?
{
    try 
    {
        int []a = {1, 2, 3, 4, 5};
        for (int i = 0; i < 5; ++i) 
        Console.WriteLine(a[i]);
        int x = (1 / Convert.ToInt32(0));
    }
    catch(IndexOutOfRangeException e) 
    {
        Console.WriteLine("A");         
    }
    catch(ArithmeticException e) 
    {      
        Console.WriteLine("B");
    }
    Console.ReadLine();
}

a.

1234

b.

12345

c.

Run time error

d.

12345B

Posted under C# programming

Answer: (d).12345B

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What will be the output of the following set of code?