adplus-dvertising

Welcome to the Indexers and Exception Handling MCQs Page

Dive deep into the fascinating world of Indexers and Exception Handling with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Indexers and Exception Handling, a crucial aspect of C# programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Indexers and Exception Handling, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within C# programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Indexers and Exception Handling. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of C# programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Indexers and Exception Handling. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Indexers and Exception Handling MCQs | Page 10 of 13

Discuss
Answer: (b).a program can contain multiple finally clauses
Q92.
Choose the correct output for given set of code:
class Program
  {
      static void Main(string[] args)
      {            
          try 
          {
              Console.WriteLine("csharp" + " " + 1/0);
          }
          finally
          {
              Console.WriteLine("Java");         
          }
          Console.ReadLine();
      }
  }
Discuss
Answer: (b).Run time Exception generation
Q93.
What will be the output of the following set of code?
{
      int sum = 10;
      try
      {
          int i;
          for (i = -1; i < 3; ++i)
          sum = (sum / i);
      }
      catch (ArithmeticException e)
      {
          Console.WriteLine("0");
      }
      Console.WriteLine(sum);
      Console.ReadLine();
  }
Discuss
Answer: (c).0 -10
Q94.
What will be the output of the following set of code?
{
    try 
    {
        int []a = {1, 2, 3, 4, 5};
        for (int i = 0; i < 5; ++i) 
        Console.WriteLine(a[i]);
        int x = (1 / Convert.ToInt32(0));
    }
    catch(IndexOutOfRangeException e) 
    {
        Console.WriteLine("A");         
    }
    catch(ArithmeticException e) 
    {      
        Console.WriteLine("B");
    }
    Console.ReadLine();
}
Discuss
Answer: (d).12345B
Q95.
What will be the output of given code snippet?
{
    try 
    {
        int []a = {1, 2, 3, 4, 5};
        for (int i = 0; i < 7; ++i) 
        Console.WriteLine(a[i]);
    }
    catch(IndexOutOfRangeException e) 
    {
        Console.WriteLine("0");         
    }
    Console.ReadLine();
}
Discuss
Answer: (b).123450
Q96.
What would be the output of following code snippet?
{
     try 
     {
         int a, b;
         b = 0;
         a = 10 / b;
         Console.WriteLine("A");
     }
     catch(ArithmeticException e) 
     {
         Console.WriteLine("B");         
     }
     Console.ReadLine();
 }
Discuss
Answer: (b).B
Q97.
What would be the output of following code snippet?
{
     try 
     {
         int i, sum;
         sum = 10;
         for (i = -1 ;i < 3 ;++i) 
         {
             sum = (sum / i);
             Console.WriteLine(i);
         }
     }
     catch(ArithmeticException e) 
     {
         Console.WriteLine("0");
     }
     Console.ReadLine();
 }
Discuss
Answer: (c).-1 0
Q98.
What would be the output of following code snippet?
{
     try 
     {
         int a, b;
         b = 0;
         a = 5 / b;
         Console.WriteLine("A");
     }
     catch(ArithmeticException e) 
     {
         Console.WriteLine("B");
     }
     finally
     {
         Console.WriteLine("C");
     }
     Console.ReadLine();
 }
Discuss
Answer: (c).B C
Q99.
What would be the output of given 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 occured");
         }
         Console.WriteLine("Program executed");
     }
 }
Discuss
Answer: (c).Exception occured
Program executed
Q100.
When no exception is thrown at runtime then who will catch it?
Discuss
Answer: (a).CLR

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!