header1.html

Tuesday 9 April 2013

C# Quiz-5(Exception Handling)


C# Quiz-5(Exception Handling)
1.Exceptions are types that all ultimately derive from ...
System.Exception
System
System.Error
All of above


2. Use a ....block around the statements that might throw exceptions.
catch
finally
try
None of these


3.In C#,.....keyword is used to define an exception handler.
catch
finally
exception
None of above


4.which block is used to release resources, for example to close any streams or files that were opened in the try block?
try
catch
finally
all of above


5.
try
{
int a,b;
b=a/0;    // Code to try goes here.
}
catch (Exception ex)
{
    Console.WriteLine("Got it!!!");
}
catch (DivideByZeroException ex)
{
    Console.WriteLine("Infinite value!!!");
}
What will be output?
  

Got it!!!
Infinite value!!!
Compile time error
Run time error


6.The user-defined application exception classes derived from ApplicationException.True or False?
True
False


7.The pre-defined common language runtime exception classes derived from SystemException.
True
False


8.Which property is used to get a string representation of the immediate frames on the call stack.
CallStack
StackTrace
Message
Source


9.Supplementary information about the exception can be stored in the...property.
HResult
Source
Data
TargetSite


10.What will be output of following program?
using System;
class ExceptionTestClass 
{
   public static void Main() 
   {
      int x = 0;
      try 
      {
         int y = 100/x;
      }
         catch (ArithmeticException e) 
         {
            Console.WriteLine("ArithmeticException Handler");
         }
         catch (Exception e) 
         {
            Console.WriteLine("Generic Exception Handler");
         }
   } 
}


Compile time error
Generic Exception Handler
ArithmeticException Handler
None of above

No comments:

Post a Comment