Will the following code compile (as part of a method):
 
string[] str = new string[5]; 
try 
{ 
     str[4] = "anything"; 
} 
catch (Exception e) 
{ 
     Console.WriteLine(e.Message); 
} 
catch (IndexOutOfRangeException e) 
{ 
     Console.WriteLine(e.Message); 
}
 
Explanation
Code will not compile.
Exception handling must be in ascending order through the hierarchy of exceptions (from child classes to superclasses).

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes