C# Try, catch and finally blocks

Question posted in Computer Software on 06 2010
Rate question difficulty level 1 Votes
what will be the output of the following Code?
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(ok());
Response.Write("
");
Response.Write(fail());
}

private string ok()
{
string x;
try
{
x = "some string";
return x;
}
catch
{
}
finally
{
x = "finally";
}

return x;


}

private string fail()
{
string x;
try
{
x = "some string";
throw new Exception();
//return x;
}
catch
{
}
finally
{
x = "finally";
}

return x;
}

A. some string,some string
B. some string,finally
C. some string,finally,some string
D. some string,finally,finally
 
 
2 Answers
 
The right answer is B

06/09/2010
 
 
Its B

06/13/2010
 
 
Add an answer*
 
Your name
Email
 
Company: iForex
Location: Israel
C# Try and Catch Finally

add a question

arrow_blue


Now hiring!
---------------------------
---------------------------
---------------------------
---------------------------
Mercer 
---------------------------
---------------------------
---------------------------