c#異常處理
try
catch
final
finally
Correct answer: 3
final
The final keyword is not used to handle exceptions in C#.NET.
嘗試
抓住
最后
最后
正確答案:3
最后
final關鍵字不用于處理C#.NET中的異常。
through
throw
final
caught
Correct answer: 2
throw
The throw is a valid keyword used in exception handling.
通過
扔
最后
抓住
正確答案:2
扔
throw是異常處理中使用的有效關鍵字。
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.
C#.NET不支持throw關鍵字
throw關鍵字用于以編程方式引發異常對象
throw關鍵字在.NET Framework的較舊版本中使用
throw關鍵字必須與try塊一起使用
正確答案:2
throw關鍵字用于以編程方式引發異常對象
關于throw關鍵字的第二條語句是正確的。
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.
除零發生異常
語法錯誤
鏈接器錯誤
無輸出
正確答案:1
除零發生異常
上面的代碼將在控制臺屏幕上顯示“發生零除零異常”。
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,
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 " ) ;
}
}
}
}
是的,最后會執行
不,最終將無法執行
正確答案:1
是的,最后會執行
是的,finally塊將執行。
輸出將是
翻譯自: https://www.includehelp.com/dot-net/csharp-exception-handling-aptitude-questions-and-answers-4.aspx
c#異常處理