1. What is Exception Handling in .NET?
Explanation: Exception handling is a mechanism in .NET used to detect and handle runtime errors in a structured manner.
Report for correction2. In .NET, which exception is thrown when an arithmetic operation results in an overflow?
Explanation: An OverflowException is thrown when an arithmetic operation results in an overflow or underflow.
Report for correction3. In .NET, which exception is thrown when an attempt is made to divide a number by zero?
Explanation: A DivideByZeroException is thrown when attempting to divide a number by zero.
Report for correction4. Which exception is raised when an attempt is made to access an array element with an invalid index?
Explanation: The IndexOutOfRangeException is thrown when an attempt is made to access an array element with an invalid index.
Report for correction5. Which exception is thrown when an invalid type conversion is attempted in C#?
Explanation: An InvalidCastException is thrown when an invalid type conversion is attempted in C#.
Report for correction6. Which keyword is used to throw an exception in C#?
Explanation: The throw keyword is used to explicitly throw an exception in C#.
Report for correction7. Which keyword is used to specify the code to be executed regardless of whether an exception occurs or not?
Explanation: The finally block is used to specify code that should execute regardless of whether an exception occurs or not.
Report for correction8. In .NET, which exception is thrown when a format of a given date or time is invalid?
Explanation: A FormatException is thrown when the format of a given date or time is invalid.
Report for correction9. Which exception is thrown when a null reference is dereferenced in C#?
Explanation: A NullReferenceException is thrown when attempting to dereference (access) a null reference.
Report for correction10. What does the finally block in a try-catch-finally statement do?
Explanation: The finally block contains code that is guaranteed to execute, whether an exception is thrown or not.
Report for correction11. Which exception is thrown when an operation is performed on an object that is in an invalid state?
Explanation: An InvalidOperationException is thrown when an operation is performed on an object that is in an invalid state.
Report for correction12. Which exception is raised when a format of a given string is invalid in .NET?
Explanation: A FormatException is thrown when the format of a given string is invalid.
Report for correction13. Which namespace contains the core exception classes in .NET?
Explanation: The core exception classes in .NET are part of the System namespace.
Report for correction14. In exception handling, what does the term "stack unwinding" refer to?
Explanation: Stack unwinding refers to the process of releasing resources in the reverse order of their allocation when an exception is thrown.
Report for correction15. What is the purpose of the when keyword in a catch block?
Explanation: The when keyword is used to filter exceptions based on specified conditions in a catch block.
Report for correction16. What is Exception Handling in .NET?
Explanation: The try-catch block is used to catch and handle exceptions, allowing for graceful error recovery.
Report for correction17. What is the purpose of the try block in exception handling?
Explanation: The try block is used to enclose code that may potentially throw exceptions.
Report for correction18. What is the purpose of the using statement in C# when working with exceptions?
Explanation: The using statement is used to ensure the proper disposal of resources, such as file streams, even in the presence of exceptions.
Report for correction19. What is the purpose of the throw statement in exception handling?
Explanation: The throw statement is used to explicitly raise (throw) an exception in C#.
Report for correction20. What is the purpose of the catch block in exception handling?
Explanation: The catch block is used to handle and process exceptions that are caught.
Report for correction21. What is the primary purpose of exception handling in software development?
Explanation: The primary purpose of exception handling is to gracefully handle runtime errors and provide a mechanism for error recovery.
Report for correction22. What is the primary purpose of custom exceptions in .NET?
Explanation: Custom exceptions are primarily used to provide detailed error information specific to an application.
Report for correction23. Which exception is thrown when there is a failure to access a file or directory in .NET?
Explanation: An UnauthorizedAccessException is thrown when there is a failure to access a file or directory due to permissions.
Report for correction24. Which of the following is not a predefined exception in .NET?
Explanation: User-defined exceptions are created by developers, while the others are predefined in .NET.
Report for correction25. Which of the following keywords is used to catch multiple exceptions in a single catch block?
Explanation: Multiple exceptions can be caught in a single catch block using the catch keyword followed by the exception types.
Report for correction