adplus-dvertising
frame-decoration

Question

Choose the correct output for the given set of code:
class program
 {
     static void main(string[] args)
     {
         int i = 5;
         int v = 40;
         int[] p = new int[4];
         try
         {
             p[i] = v;
         }
         catch(IndexOutOfRangeException e)
         {
             Console.WriteLine("Index out of bounds");
         }
         Console.WriteLine("Remaining program");
     }
 }

a.

value 40 will be assigned to a[5];

b.

The output will be :
Index out of bounds
Remaining program

c.

The output will be :
Remaining program

d.

None of the mentioned

Posted under C# programming

Answer: (b).The output will be :
Index out of bounds
Remaining program

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Choose the correct output for the given set of code: