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(); } }
class program { public static void Main(string[] args) { try { throw new NullReferenceException("C"); Console.WriteLine("A"); } catch (ArithmeticException e) { Console.WriteLine("B"); } Console.ReadLine(); } }
Answer: Option D
Was this answer helpful ?
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 ?
Submit Solution