What will be the output of the given code?
using System;
class MyProgram {
static void Main(string[] args) {
try {
int a, b;
b = 0;
a = 5 / b;
Console.WriteLine("No exception will occur.");
} catch (ArithmeticException e) {
Console.WriteLine("Exception occurs.");
} finally {
Console.WriteLine("Program is executed.");
}
Console.ReadLine();
}
}
A
Program is executed.
B
No exception will occur.
C
Exception occurs.
Program is executed.
D
No exception will occur.
Program is executed.
Output of the given code
is
Exception occurs.
Program is executed.
because 5/0 throws ArithmeticException
Exception occurs.
Program is executed.
Get Answers For Free
Most questions answered within 1 hours.