Question
class Program
{
public static void Main(string[] args)
{
try
{
int a = args.Length;
int b = 10 / a;
Console.WriteLine(a);
try
{
if (a == 1)
a = a / a - a;
if (a == 2)
{
int[] c = { 1 };
c[8] = 9;
}
}
catch (IndexOutOfRangeException e)
{
Console.WriteLine("TypeA");
}
}
catch (ArithmeticException e)
{
Console.WriteLine("TypeB");
}
Console.ReadLine();
}
}
a.
TypeA
b.
TypeB
c.
0TypeA
d.
Compile time error
Posted under C# programming
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 given code snippet?
Similar Questions
Discover Related MCQs
Q. Which of these exceptions will occur if we try to access the index of an array beyond its length?
View solution
Q. Which of these exceptions handles the divide by zero error?
View solution
Q. A single try block must be followed by which of these?
View solution
Q. Which of these clauses will be executed even if no exceptions are found?
View solution
Q. Choose the correct statement which makes exception handling work in C#.NET?
View solution
Q. When no exception is thrown at runtime then who will catch it?
View solution
Q. Which of the following is the wrong statement about exception handling in C#.NET?
View solution
Q. Which of these keywords is used to manually throw an exception?
View solution
Q. Which of these keywords must be used to monitor exceptions?
View solution
Q. Which of these keywords is not a part of exception handling?
View solution
Q. Select the correct statement about an Exception?
View solution
Q. Select the statements which describe the correct usage of exception handling over conventional error handling approaches?
View solution
Q. Which of the following is the object oriented way to handle run time errors?
View solution
Q. Which among the following is considered as .NET Exception class?
View solution
Q. Which among the following is NOT an exception?
View solution
Q. Select the correct statement about properties of read and write in C#.NET?
View solution
Q. If the math class had add property with get accessors then which of the following statements will work correctly?
View solution
Q. If math class had add property with get and set accessors, then which of the following statements will work correctly?
View solution
Q. Consider a class maths and we had a property called as sum.b is a reference to a maths object and we want the code below to work.Which is the correct solution to ensure this functionality?
b.maths = 10;
Console.WriteLine(b.maths);
View solution
Q. Consider a class maths and we had a property called as sum.b which is the reference to a maths object and we want the statement Console.WriteLine(b.sum)to fail.Which among the following is the correct solution to ensure this functionality?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond C# programming? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!