Discussion :: C#.Net MCQs
-
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();}}
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