Requirement is:

try
{
\\SQL Query
}
catch(Exception i)
{
print a
}
catch(SQLQueryException e)
{
\\SQL Query
}


Qu)I Got Exception in "try" block. Which "catch" statement
(i.e. 1st catch or 2nd catch ) catches the exception and
Why???

Answers were Sorted based on User's Feedback



Requirement is: try { \\SQL Query } catch(Exception i) { print a } catch(SQLQ..

Answer / parikshit

it will give compile time error as, the sequence of
exception class has to be Most Specific => General.

Is This Answer Correct ?    12 Yes 3 No

Requirement is: try { \\SQL Query } catch(Exception i) { print a } catch(SQLQ..

Answer / sathish

There will be compile time error, becuase
the "..........catch(Exception ex)..........." is generic
exception block, where all type of exceptions are caught,
so when "catch(Exception ex)" is placed in the beginning,
then the following compile time error is thrown.

"A previous catch clause already catches all exceptions of
this or of a super type ('System.Exception')"

Is This Answer Correct ?    10 Yes 1 No

Requirement is: try { \\SQL Query } catch(Exception i) { print a } catch(SQLQ..

Answer / meena

In try block the SQL query will be executed so the exception
will match the SQLException catch because all type of SQL
exception will be match in this SQLException

if we wrote normal query in try block then it will match
Exception catch

Is This Answer Correct ?    5 Yes 2 No

Requirement is: try { \\SQL Query } catch(Exception i) { print a } catch(SQLQ..

Answer / sabir

when the exception is thrown it will search for mostly
likely to least likely exception so it will catch in second
catch

Is This Answer Correct ?    11 Yes 11 No

Requirement is: try { \\SQL Query } catch(Exception i) { print a } catch(SQLQ..

Answer / mathew m

it will give error

previous catch clause already catches all exceptions of
this or of a super type ('System.Exception')

b"z System.Exception is the MOTHER -"mathaji" of all
exception.So all will be caught intitally,after that no
exception remains...it will be ok if we put child exception
like "SQLQueryException" before Exception [mathaji:)]

Is This Answer Correct ?    2 Yes 2 No

Requirement is: try { \\SQL Query } catch(Exception i) { print a } catch(SQLQ..

Answer / balakrishnan

The First Catch block will be executed, if the generic
exception should be defined it should be the last of
exception list

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More Dot Net Framework Interview Questions

When do you absolutely have to declare a class as abstract

1 Answers   Siebel Systems,


If foreground completes its processing will it wait for background threads?

1 Answers   Kanbay,


Explain Bundle.Config in ASP.Net MVC4?

0 Answers  


What is razor code?

0 Answers  


What type of filter does outputcacheattribute class represents?

0 Answers  


How to change the action name in ASP.Net MVC?

0 Answers  


what do you mean by navigation property?

0 Answers   Microsoft,


How to identify the Code which Complies corresponding Compiler in .NET? Means Suppose, i am taking One project A.. in which code is implemented using C# langugge. And Another Project B..in Which Code is implemented using VB.NET. Suppose I am creating Project C. i am adding Reference of Project A and B to Project C. So, in Project C, how to identify Project A is Complied through CSCompliler? And Project B is Compiled VBCompiler at Runtime?

1 Answers  


About Assembly in .NET, types of assemblies, their difference, How to register into GAC. How to generate the strong names & its use ?

6 Answers   Infosys, Microsoft, MMTS,


What is RouteConfig.cs in ASP.Net MVC 4?

0 Answers  


Can source code be reverse-engineered from IL?

2 Answers  


what is mean by COM (component object model) and component based software development? Is it .NET is first COM based technology? Please answer me. Advance thanks.

1 Answers   Excel,


Categories