1) How many times can we use to try block in a C# program?
- 5 times
- 2 times
- Any number of times
- Only one time
Correct answer: 3
Any number of times
We can use try block any number of times in a c# program.
2) There are following statements are given below, which is correct about catch block in C#.NET?
- The catch is not supported in C#.NET
- The catch block is used to catch on number related exceptions
- The catch block executes at least once during program execution
- The catch block is used to catch all types of exceptions that occurred in a try block, depends upon its exception class
Correct answer: 4
The catch block is used to catch all types of exceptions that occurred in a try block, depends upon its exception class
The 4th statement is correct for the catch block.
3) There are following statements are given below, which is correct about finally block in C#.NET?
- The finally block is not supported in C#.NET
- The finally block is also used to catch exceptions
- The finally block can contain only a single statement inside it
- The finally block execute at least once, whether exception caught in block or not
Correct answer: 4
The finally block execute at least once, whether exception caught in block or not
The 4th statement is correct for finally block.
4) Can we use a catch block without using a try block in C#.Net?
- Yes
- No
Correct answer: 2
No
We cannot use a catch block without a try block.
5) If we define a try block and did not define any catch or finally block, will it work?
- Yes
- No
Correct answer: 2
No
Only try block cannot be defined, we must define associated catch or finally block with it.