250+ TOP MCQs on Fundamentals of Exception Handling and Answers

C# multiple choice questions on fundamentals of the exception handling in C# Programming Language.

1. Which among the following is NOT an exception?
a) Stack Overflow
b) Arithmetic Overflow or underflow
c) Incorrect Arithmetic Expression
d) All of the mentioned

Answer: c
Clarification: None.

2. Which among the following is considered as .NET Exception class?
a) Exception
b) StackUnderflow Exception
c) File bound Exception
d) All of the mentioned

Answer: b
Clarification: None.

3. Which of the following is the object oriented way to handle run time errors?
a) Error codes
b) HERRESULT
c) OnError
d) Exceptions

Answer: d
Clarification: None.

4. Select the statements which describe the correct usage of exception handling over conventional error handling approaches?
a) As errors can be ignored but exceptions cannot be ignored
b) Exception handling allows separation of program’s logic from error handling logic making software more reliable and maintainable
c) try – catch – finally structure allows guaranteed cleanup in event of errors under all circumstances
d) All of the mentioned

Answer: d
Clarification: None.

5. Select the correct statement about an Exception?
a) It occurs during loading of program
b) It occurs during Just-In-Time compilation
c) It occurs at run time
d) All of the mentioned

Answer: c
Clarification:None.

6. Which of these keywords is not a part of exception handling?
a) try
b) finally
c) thrown
d) catch

Answer: c
Clarification: Exception handling is managed via 5 keywords – try, catch, throws, throw and finally.

7. Which of these keywords must be used to monitor exceptions?
a) try
b) finally
c) throw
d) catch

  250+ TOP MCQs on Switch Statements and Answers

Answer: a
Clarification: None.

8. Which of these keywords is used to manually throw an exception?
a) try
b) finally
c) throw
d) catch

Answer: c
Clarification: None.

9. What will be the output of the following C# code?

  1.  class program
  2.  {
  3.      static void main(string[] args)
  4.      {
  5.          int i = 5;
  6.          int v = 40;
  7.          int[] p = new int[4];
  8.          try
  9.          {
  10.              p[i] = v;
  11.          }
  12.          catch(IndexOutOfRangeException e)
  13.          {
  14.              Console.WriteLine("Index out of bounds");
  15.          }
  16.          Console.WriteLine("Remaining program");
  17.      }
  18.  }

a) value 40 will be assigned to a[5];
b)

The output will be :
Index out of bounds
Remaining program

c)

The output will be :
Remaining program

d) None of the mentioned

Answer: b
Clarification:None.

10. What will be the output of the following C# code?

  1.  static void Main(string[] args)
  2.  {
  3.      try
  4.      {
  5.          Console.WriteLine("csharp" + " " + 1/Convert.ToInt32(0));
  6.      }
  7.      catch(ArithmeticException e)
  8.      {
  9.          Console.WriteLine("Java");
  10.      }
  11.      Console.ReadLine();
  12.  }

a) csharp
b) java
c) run time error
d) csharp 0

Answer: b
Clarification: 1 / 0, hence system out of flow exception error.

11. Which of the following is the wrong statement about exception handling in C#.NET?
a) finally clause is used to perform cleanup operations of closing network and database connections
b) a program can contain multiple finally clauses
c) the statement in final clause will get executed no matter whether an exception occurs or not
d) all of the mentioned

Answer: b
Clarification: None.

12. What will be the output of the following C# code?

  1.   class Program
  2.   {
  3.       static void Main(string[] args)
  4.       {
  5.           try
  6.           {
  7.               Console.WriteLine("csharp" + " " + 1/0);
  8.           }
  9.           finally
  10.           {
  11.               Console.WriteLine("Java");
  12.           }
  13.           Console.ReadLine();
  14.       }
  15.   }

a) csharp 0
b) Run time Exception generation
c) Compile time error
d) Java

Answer: b
Clarification: Run time Error of division by zero.

  250+ TOP MCQs on Use of Variable Number of Arguments and Answers

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top