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

6/6

Page

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

What will be the output of the following C# code snippet?
class Output 
{
    public static void main(String args[]) 
    {
        try 
        {
            int a = 10;
            int b = 5;
            int c =  b - 5 / 5;
            Console.WriteLine("Hi");
        }
        catch(Exception e) 
        {
            Console.WriteLine("hello");
        } 
    }
}

Select an option to see the answer and solution.

Choose the correct alternative that utilizes the indexed property such that a group named class has indexed property which stores or retrieves value to/from an array of 5 numbers?

Select an option to see the answer and solution.

Which among the following are the advantages of using indexers?

Select an option to see the answer and solution.

What will be the output of the following C# code snippet?
class Program
{
    static void Main(string[] args)
    {
        int i;
        int v = 40;
        int[] x = new int[5];
        try
        {
            Console.WriteLine(" Enter the number: ");
            index = Convert.ToInt32(Console.ReadLine());
            x[index] = v;
        }
        catch(Exception e)
        {
            Console.WriteLine("Exception occurred");
        }
        Console.WriteLine("Program executed");
    }
}

Select an option to see the answer and solution.

Which of these keywords must be used to monitor exceptions?

Select an option to see the answer and solution.

Select the correct statement about properties of read and write in C#.NET?

Select an option to see the answer and solution.

Consider a class maths and we had a property called a sum.b is a reference to a maths object and we want the statement b.sum = 10 to fail. Which of the following is the correct solution to ensure this functionality?

Select an option to see the answer and solution.