c#异常处理_C#异常处理能力问题和解答 套装4
c#異常處理
1) Which is not a valid keyword used in the context of exception handling?try
catch
final
finally
Correct answer: 3
final
The final keyword is not used to handle exceptions in C#.NET.
1)在異常處理的上下文中使用哪個無效關鍵字?嘗試
抓住
最后
最后
正確答案:3
最后
final關鍵字不用于處理C#.NET中的異常。
2) Which is a valid keyword used in the context of exception handling?through
throw
final
caught
Correct answer: 2
throw
The throw is a valid keyword used in exception handling.
2)在異常處理的上下文中使用哪個有效關鍵字?通過
扔
最后
抓住
正確答案:2
扔
throw是異常處理中使用的有效關鍵字。
3) There are following statements are given below, which is correct about throw in C#.NET?The throw keyword is not supported in C#.NET
The throw keyword is used to throw an exception object programmatically
The throw keyword is used in older versions of the .NET framework
The throw keyword is mandatory to use with the try block
Correct answer: 2
The throw keyword is used to throw an exception object programmatically
The 2nd statement is correct about throw keyword.
3)下面給出以下語句,關于C#.NET中的拋出正確嗎?C#.NET不支持throw關鍵字
throw關鍵字用于以編程方式引發(fā)異常對象
throw關鍵字在.NET Framework的較舊版本中使用
throw關鍵字必須與try塊一起使用
正確答案:2
throw關鍵字用于以編程方式引發(fā)異常對象
關于throw關鍵字的第二條語句是正確的。
4) What is the correct output of the given code snippet? using System;namespace my_namespace {class program{static void Main(string[] args){int a = 0;int b = 10;int c = 0;try{c = b / a;}catch (DivideByZeroException d){Console.WriteLine("Divide by zero exception occurred");}}} }Divide by zero exception occurred
Syntax error
Linker error
No output
Correct answer: 1
Divide by zero exception occurred
The above code will print "Divide by zero exception occurred" on the console screen.
4)給定代碼段的正確輸出是什么?除零發(fā)生異常
語法錯誤
鏈接器錯誤
無輸出
正確答案:1
除零發(fā)生異常
上面的代碼將在控制臺屏幕上顯示“發(fā)生零除零異常”。
5) In the given code snippet finally block will execute or not? using System;namespace my_namespace {class program{static void Main(string[] args){int a = 0;int b = 10;int c = 0;try{c = b / a;}finally{Console.WriteLine("Finally executed");}}} }Yes, finally will execute
No, finally will not execute
Correct answer: 1
Yes, finally will execute
Yes, finally block will execute.
The output would be,
5)在給定的代碼片段中,finally塊是否會執(zhí)行? using System ;namespace my_namespace {class program{static void Main ( string [ ] args ){int a = 0 ;int b = 10 ;int c = 0 ;try{c = b / a ;}finally{Console . WriteLine ( " Finally executed " ) ;}}} }是的,最后會執(zhí)行
不,最終將無法執(zhí)行
正確答案:1
是的,最后會執(zhí)行
是的,finally塊將執(zhí)行。
輸出將是
? C# Exception Handling Aptitude | Set 4 C# Exception Handling Aptitude | Set 5 ? #C#異常處理能力| 設置4 C#異常處理能力| 設置5?翻譯自: https://www.includehelp.com/dot-net/csharp-exception-handling-aptitude-questions-and-answers-4.aspx
c#異常處理
總結
以上是生活随笔為你收集整理的c#异常处理_C#异常处理能力问题和解答 套装4的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: lnmp解析php,LNMP之 php解
- 下一篇: 修改console缓存大小_更改缓存的行