C# Programming Questions and Answers
Which among the following is NOT considered as .NET Exception class?
Answer: Option (B) and Option (C)
Select the statements which describe the correct usage of exception handling over conventional error handling approaches?
Answer: Option (D)
Which among the following is NOT an exception?
Answer: Option (C)
Which of the following is the correct statement about exception handling in C#.NET?
Answer: Option (A) and Option (C)
Which of these keywords is not a part of exception handling?
Exception handling is managed via 5 keywords – try, catch, throws, throw and finally.
Choose the correct output for the given set of code:
class program
{
staticvoid main(string[] args)
{
int i =5;
int v =40;
int[] p =newint[4];
try
{
p[i]= v;
}
catch(IndexOutOfRangeException e)
{
Console.WriteLine("Index out of bounds");
}
Console.WriteLine("Remaining program");
}
}
Answer: Option (B)
Choose the correct output for the given set of code:
staticvoid Main(string[] args)
{
try
{
Console.WriteLine("csharp"+" "+1/Convert.ToInt32(0));
}
catch(ArithmeticException e)
{
Console.WriteLine("Java");
}
Console.ReadLine();
}
1 / 0, hence system out of flow exception error.