CSE MCQs :: 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();}}
-
What will be the output of the given code snippet? class Program{public static void Main(string[] args){try{int a = 1;int b = 10 / a;try{if (a == 1)a = a / a - a;if (a == 2){int[] c = { 1 };c[8] = 9;}}finally{Console.WriteLine("A");}}catch (IndexOutOfRangeException e){Console.WriteLine("B");}Console.ReadLine();}}
-
What would be the output of following code snippet? {try{int a, b;b = 0;a = 5 / b;Console.WriteLine("A");}catch(ArithmeticException e){Console.WriteLine("B");}finally{Console.WriteLine("C");}Console.ReadLine();}
-
What would be the output of given code snippet? class Program{static void Main(string[] args){int i;int v = 40;int[] x = new int[5];try{Console.WriteLine(" Enter the number: ");index = Convert.ToInt32(Console.ReadLine());x[index] = v;}catch(Exception e){Console.WriteLine("Exception occured");}Console.WriteLine("Program executed");}}
- Choose the correct statement among the following?
- Consider a class maths and we had a property called as sum.b is a reference to a maths object and we want the statement b.sum = 10 to fail.Which of the following is the correct solution to ensure this functionality?
- Consider a class maths and we had a property called as sum.b which is the reference to a maths object and we want the statement Console.WriteLine(b.sum)to fail.Which among the following is the correct solution to ensure this functionality?
- Which of these keywords are used for the block to handle the exceptions generated by try block?
A.
A property can be a static member whereas an indexer is always an instance member
|
B.
A get accessor of a property corresponds to a method with no parameters whereas get accessor of an indexer corresponds to a method with the same formal parameters lists as the indexer
|
C.
It is an error for indexer to declare a local variable with the same name as indexer parameters
|
D.
All of the mentioned
|