Answer Posted / shadab alam
yes two catch block can be executed .
Sorry for privious Error!whrer two catch block are not
executd but this time it has been executed
Now This is right answer here two
using System;
class a
{
public static void Main()
{
int a=8;
int b=0;
int [] arr=new int[]{1,2};
try
{
Console.WriteLine(a/b);
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
Console.WriteLine("Hello");
}
finally
{ try
{
Console.WriteLine(arr[2]);
}
catch(IndexOutOfRangeException d)
{
Console.WriteLine(d.ToString
()+ "hello");
Console.WriteLine("Hello");
}
}
}
}
output will be
----------------
System.DivideByZeroException: Attempted to divide by zero.
at a.Main()
Hello
System.IndexOutOfRangeException: Index was outside the
bounds of the array.
at a.Main()hello
Hello
| Is This Answer Correct ? | 12 Yes | 3 No |
Post New Answer View All Answers
What is the difference between abstract and abstraction?
What floating point types is supported in C#?
What is response redirect in c#?
What does an indexer do?
What is routing in c#?
Explain about Oops concept
How to declare a property in a class?
What is a copy constructor in c#?
Why would you use a class property in c#?
Can we extend sealed class in c#?
What is the use of 'using' statement in c#?
Can properties be private in c#?
Which sorting algorithm is best?
How to move to a state-related codebase?
What is a view? What is the use of it?