If all code is written in a try block and write a catch
block with Exception type Exception .In that scenario will
all the exceptions catched by that catch block? or any
exceptions which will not be caught?

Answers were Sorted based on User's Feedback



If all code is written in a try block and write a catch block with Exception type Exception .In tha..

Answer / parmjit

Yes all the exceptions will be catched by this catch block.
Because all the thrown exception as derived from this class
or it's sub class.

Because even if any exception occured which is not derived
from the Exception class, it is automatically wrapped in
RuntimeWrappedException which is a derived class of
Exception class.

Is This Answer Correct ?    5 Yes 0 No

If all code is written in a try block and write a catch block with Exception type Exception .In tha..

Answer / pompana gouda

Yes and No is the answer...
Yes because, Any type of exception will be caught by general
catch block.

No because,
If there are 3 lines which generate 3 different exceptions,
Then only first exception is caught in the general exception
catch block. If first line is not throwing exception then
whatever the line which throws exception will be caught...
Not all exceptions are handled by single catch statement.

Is This Answer Correct ?    5 Yes 0 No

If all code is written in a try block and write a catch block with Exception type Exception .In tha..

Answer / vinay tiwari

if we use some piece of code that return in different
language then there may be exception that are not define in
exception class to catch these type of exception we use
general catch handler
for exe
try
{
........
}
catch
{
..........
} //catch block without parameter is called general catch
handler

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Sharp Interview Questions

Can you change the value of a variable while debugging a C# application?

1 Answers   Siebel Systems, Wipro,


What does the parsefloat function do?

0 Answers  


What is Global Assembly Cache (GAC) and what is the purpose of it? (How to make an assembly to public? Steps) How more than one version of an assembly can keep in same place?

0 Answers  


What is ienumerator c#?

0 Answers  


how to retrieve binary data from database (using c#.net and sql server/windows application)

2 Answers   Soltius,


What is the difference while using directive vs using statement ?

0 Answers  


Can a struct inherit from an interface in c#?

0 Answers  


What is jit (just in time)?

0 Answers  


What is the use of inheritance in c#?

0 Answers  


What is Interface and Abstraction (in real time scenario)

4 Answers   HCL,


What is the difference between and xml documentation tag?

0 Answers  


what is the purpose of Interfaces?

7 Answers   HCL,


Categories