C# Programming :: Exception Handling
-
Which of the following is NOT a .NET Exception class?
-
Which of the following statements is correct about an Exception?
-
In C#.NET if we do not catch the exception thrown at runtime then which of the following will catch it?
-
Which of the following statements is correct about the C#.NET program given below?
using System; namespace FreshergateConsoleApplication { class MyProgram { static void Main(string[] args) { int index = 6; int val = 44; int[] a = new int[5]; try { a [index] = val ; } catch(IndexOutOfRangeException e) { Console.Write("Index out of bounds "); } Console.Write("Remaining program"); } } }
-
Which of the following statements are correct about exception handling in C#.NET?
- If an exception occurs then the program terminates abruptly without getting any chance to recover from the exception.
- No matter whether an exception occurs or not, the statements in the finally clause (if present) will get executed.
- A program can contain multiple finally clauses.
- A finally clause is written outside the try block.
- finally clause is used to perform clean up operations like closing the network/database connections.
-
Which of the following statements are correct about exception handling in C#.NET?
- If our program does not catch an exception then the .NET CLR catches it.
- It is possible to create user-defined exceptions.
- All types of exceptions can be caught using the Exception class.
- CLRExceptions is the base class for all exception classes.
- For every try block there must be a corresponding finally block.
-
Which of the following statements are correct about the exception reported below?
Unhandled Exception: System.lndexOutOfRangeException: Index was outside the bounds of the array: at FreshergateConsoleApplication.MyProgram.SetVal(Int32 index, Int32 val) in D:\Sample\FreshergateConsoleApplication\MyProgram.cs:line 26 at FreshergateConsoleApplication.MyProgram.Main(String[] args) in D:\Sample\FreshergateConsoleApplication\MyProgram.cs:line 20- The CLR failed to handle the exception.
- The class MyProgram belongs to the namespace MyProgram.
- The function SetVal() was called from Main() in line number 20.
- The exception occurred in line number 26 in the function SetVal()
- The runtime exception occurred in the project FreshergateConsoleApplication.
-
Which of the following statements are correct about the exception reported below?
Unhandled Exception: System.lndexOutOfRangeException: Index was outside the bounds of the array: at FreshergateConsoleApplication.MyProgram.SetVal(Int32 index, Int32 val) in D:\Sample\FreshergateConsoleApplication\MyProgram.cs:line 26 at FreshergateConsoleApplication.MyProgram.Main(String[] args) in D:\Sample\FreshergateConsoleApplication\MyProgram.cs:line 20- The CLR failed to handle the exception.
- The class MyProgram belongs to the namespace MyProgram.
- The function SetVal() was called from Main() in line number 20.
- The exception occurred in line number 26 in the function SetVal()
- The runtime exception occurred in the project FreshergateConsoleApplication.
-
Which of the following statements are correct about the exception reported below?
Unhandled Exception: System.lndexOutOfRangeException: Index was outside the bounds of the array: at FreshergateConsoleApplication.MyProgram.SetVal(Int32 index, Int32 val) in D:\Sample\FreshergateConsoleApplication\MyProgram.cs:line 26 at FreshergateConsoleApplication.MyProgram.Main(String[] args) in D:\Sample\FreshergateConsoleApplication\MyProgram.cs:line 20- The CLR failed to handle the exception.
- The class MyProgram belongs to the namespace MyProgram.
- The function SetVal() was called from Main() in line number 20.
- The exception occurred in line number 26 in the function SetVal()
- The runtime exception occurred in the project FreshergateConsoleApplication.
-
Which of the following statements are correct about the exception reported below?
Unhandled Exception: System.lndexOutOfRangeException: Index was outside the bounds of the array: at FreshergateConsoleApplication.MyProgram.SetVal(Int32 index, Int32 val) in D:\Sample\FreshergateConsoleApplication\MyProgram.cs:line 26 at FreshergateConsoleApplication.MyProgram.Main(String[] args) in D:\Sample\FreshergateConsoleApplication\MyProgram.cs:line 20- The CLR failed to handle the exception.
- The class MyProgram belongs to the namespace MyProgram.
- The function SetVal() was called from Main() in line number 20.
- The exception occurred in line number 26 in the function SetVal()
- The runtime exception occurred in the project FreshergateConsoleApplication.