Exception Handling

Q1:
Which of the following statements is correct about the C#.NET program given below if a value 'ABCD' is input to it?
using System;
namespace AptitudeCrackConsoleApplication
{
    class MyProgram
    {
        static void Main(string[] args)
        {
            int index; 
            int val = 55; 
            int[] a = new int[5]; 
            try
            {
                Console.Write('Enter a number: ');
                index = Convert.ToInt32(Console.ReadLine());
                a[index] = val;
            }
            catch(FormatException e)
            {
                Console.Write('Bad Format ');
            }
            catch(IndexOutOfRangeException e)
            {
                Console.Write('Index out of bounds ');
            }
            Console.Write('Remaining program ');
        }
    }
}

A It will output: Bad Format

B It will output: Remaining program

C It will output: Index out of bounds

D It will output: Bad Format Remaining program

E It will output: Index out of bounds Remaining program

ANS:D - It will output: Bad Format Remaining program

No answer description is available. Let's discuss.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.