Vidyalelo
C# Programming · all questions

Exception Handling in C Sharp
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

107

Questions

2/6

Page

Pick an option on a question to see the right answer and solution.

In C#, what happens if an exception occurs inside a catch block?

Select an option to see the answer and solution.

Which of the following is NOT a standard exception class provided by .NET Framework in C#?

Select an option to see the answer and solution.

In C#, which keyword is used to specify that a method can throw a particular type of exception?

Select an option to see the answer and solution.

What is the process of converting a custom exception object into a standard exception object in C# called?

Select an option to see the answer and solution.

In C#, what happens if no catch block matches the exception type thrown in a try block?

Select an option to see the answer and solution.

What is the purpose of the try block in exception handling in C#?

Select an option to see the answer and solution.

In C#, which block is used to handle exceptions that may occur within a try block?

Select an option to see the answer and solution.

What is the purpose of the finally block in C# exception handling?

Select an option to see the answer and solution.

Which statement is used to throw an exception in C#?

Select an option to see the answer and solution.

In C#, which of the following keywords is used to define a custom exception class?

Select an option to see the answer and solution.

What is the term for an exception that occurs during the execution of a program in C#?

Select an option to see the answer and solution.

In C#, what is the purpose of the using statement in exception handling?

Select an option to see the answer and solution.

Which keyword is used to specify a block of code where an exception might occur in C#?

Select an option to see the answer and solution.

In C#, which class is the base class for all exceptions?

Select an option to see the answer and solution.

What is the purpose of the catch block in C# exception handling?

Select an option to see the answer and solution.

What is the term for handling an exception and continuing program execution in C#?

Select an option to see the answer and solution.

In C#, what happens if an exception is thrown inside a finally block?

Select an option to see the answer and solution.

What is the purpose of the try-catch block in C#?

Select an option to see the answer and solution.

Which statement is used to specify code that should always run regardless of whether an exception occurs in C#?

Select an option to see the answer and solution.

What will be the output of the following C# code?
class student
{
    int []scores = new int[3] {13, 32, 24};
    public int this[int index]
    {
        get
        {
            if (index < 3)
            return scores[index];
            else
            {
                Console.WriteLine("invalid index");
                return 0;
            }
        }
        private  set
        {
            if (index < 3)
            scores[index] = value;
            else
            Console.WriteLine("invalid index");
        }
    }
}
class Program
{
    public static void Main(string[] args)
    {
        student s = new student();
        int[] scores1 = new int[3] {8, 19, 40};
        for (int i = 0; i < 3; i++)
        {
            if (scores1[i] > s[i])
            {
                Console.WriteLine(" scores1 had greater value :" + scores1[i]);
            }
            else
            {
                Console.WriteLine("scores had greater value :" + s[i]);
            }
        }
        Console.ReadLine();
    }
}

Select an option to see the answer and solution.