C# Programming - Exception Handling - Discussion
Discussion Forum : Exception Handling - General Questions (Q.No. 9)
9.
Which of the following statements is correct about the C#.NET program given below if a value "6" is input to it?
using System;
namespace IndiabixConsoleApplication
{
class MyProgram
{
static void Main(string[] args)
{
int index;
int val = 44;
int[] a = new int[5];
try
{
Console.Write("Enter a number:");
index = Convert.Tolnt32(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");
}
}
}
Discussion:
1 comments Page 1 of 1.
Tyrone Atkins said:
9 years ago
Again, any attempt to assign a value to an array that has already been assigned a value previously will be erroneous.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers