C# Indexers and Exceptions Mcqs

Our collections of Multiple choice questions and answers focuses on study of C# Indexers and Exceptions. These questions are chosen from a collection of most authoritative and best reference books on C# Indexers and Exceptions. Our aim is to prepare an individual for competitive exams like NTS, GAT, ECAT, University and College entrance exams and various tests and job interviews. One should practice our Mcqs to assimilate C# Indexers and Exceptions comprehensively.

  1. Home
  2. »
  3. Languages
  4. »
  5. Programming Languages Mcqs
  6. »
  7. C# Programming Mcqs
  8. »
  9. Indexers and Exceptions Mcqs
  10. »
  11. Page 8

107.
What is the use of try & catch?

It is used to manually handle the exception

It helps to fix the errors

It prevents automatic terminating of the program in cases when an exception occurs

All of the mentioned

108.
What is the output of this program?
 class Output 
 {
     public static void main(String args[]) 
     {
 
         try 
         {
             int a = 9;
             int b = 5;
             int c = a / b - 5;
             Console.WriteLine("Hello");
         }
         catch(Exception e) 
         {
             Console.WriteLine("C");
         } 
         finally 
         {
             Console.WriteLine("sharp");
         } 
     }
 }

Hello

C

Hellosharp

Csharp

109.
Choose the statement which is incorrect?

Try block does not need to be followed by catch block

Try block can be followed by finally block instead of catch block

Try can be followed by both catch and finally block

Try need not to be followed by anything

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

Hi

Hello

Hihello

Compile time error

113.
What is the output of this program?
class Output 
  {
      public static void main(String args[]) 
      {
         try 
         {
             int a = 5;
             int b = 10;
             int c = b / a - 5;
             Console.WriteLine("Csharp");
         } 
     }
 } 

Csharp

Sharp

C

Compile time error

114.
What is the output of the given code snippet?
 class Output 
 {
     public static void main(String args[]) 
    {
        try 
        {
            int a = 0;
            int b = 5;
            int c = a / b - 5;
            Console.WriteLine("C");
        }
        finally 
        {
            Console.WriteLine("sharp");
        } 
    }
}

C

Sharp

Csharp

None of the mentioned

115.
What will be the output of the 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");
         } 
     }
 }

Hi

Hello

Hihello

Compile time error

error: You are not allowed to do so.....
0Shares
0
Scroll to Top