Sail E0 Webinar
Question
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();     } }
Options:
A .  A
B .  B
C .  Compile time error
D .  Runtime error
Answer: Option D


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.



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers