Home / CSE MCQs / C#.Net MCQs :: Discussion

Discussion :: C#.Net MCQs

  1. What will be the output of given code snippet?

     class program
     {
         public static void Main(string[] args)
         {
             try
             {
                 throw new NullReferenceException("C");
                 Console.WriteLine("A");
             }
             catch (ArithmeticException e) 
             {
                 Console.WriteLine("B");
             }
             Console.ReadLine();
         }
     }
  2. A.
    A
    B.
    B
    C.
    Compile time error
    D.
    Runtime error

    View Answer

    Workspace

    Answer : Option D

    Explanation :

    try block is throwing NullPointerException but the catch block is used to counter Arithmetic Exception. Hence NullPointerException occurs since no catch is there which can handle it, runtime error occurs.


Be The First To Comment