Delegates And Events In C Sharp MCQs
Practice Delegates And Events In C Sharp MCQs for competitive exams.
Delegates And Events In C Sharp MCQs
Practice questions from this topic.
Choose the incorrect statement among the following about the delegate?
Correct Answer: D
Which among the given classes is present in System.Collection.Generic.namespace?
Correct Answer: A
Which among the given classes represents System.Collections.Generic namespace?
Correct Answer: A
What will be the output of the following C# code snippet? { delegate string F(string str); class sample { public static string fun(string a) { return a.Replace(',''-'); } } class Program { static void Main(string[] args) { F str1 = new F(sample.fun); string str = str1("Test Your c#.NET skills"); Console.WriteLine(str); } } }
Correct Answer: B
Which of the following are the correct statements about delegates?
Correct Answer: D
Which statement is valid for the following C# code snippet? public class Generic { public T Field; } class Program { static void Main(string[] args) { Generic g = new Generic(); g.Field = "Hi"; Console.WriteLine(g.Field); } }
Correct Answer: D
What will be the output of the following C# code? public class Generic { public T Field; } class Program { static void Main(string[] args) { Generic g2 = new Generic(); Generic g3 = new Generic(); g2.Field = 8; g3.Field = 4; if (g2.Field % g3.Field == 0) { Console.WriteLine("A"); } else Console.WriteLine("Prints nothing:"); Console.ReadLine(); } }
Correct Answer: B
Suppose a Generic class called as SortObjects is to be made capable of sorting objects of any type(integer, single, byte etc). Then, which of the following programming constructs is able to implement the comparison function?
Correct Answer: C
Which of the following is the correct way to call the function abc() of the given class in the following C# code? class csharp { public int abc(int a) { Console.WriteLine("A:Just do it!"); return 0; } }
Correct Answer: C
Which of the following is an incorrect statement about delegate?
Correct Answer: C
Choose the statements which makes delegate in C#.NET different from a normal class?
Correct Answer: D
What will be the output of the following C# code snippet? public class Generic { Stack stk = new Stack(); public void push(T obj) { stk.Push(obj); } public T pop() { T obj = stk.Pop(); return obj; } } class Program { static void Main(string[] args) { Generic g = new Generic(); g.push(40); Console.WriteLine(g.pop()); Console.ReadLine(); } }
Correct Answer: C
