adplus-dvertising
frame-decoration

Question

For the code snippet given below, which of the following statements are valid?

public class MyContainer<T> where T: class, IComparable
{
//Insert code here
}

1. Class MyContainer requires that it's type argument must implement IComparable interface.
2. Compiler will report an error for this block of code.
3. There are multiple constraints on type argument to MyContainer class.
4. Class MyContainer requires that its type argument must be a reference type and it must implement IComparable interface.


a.

1 and 2 Only

b.

3 and 4 Only

c.

2 and 3 Only

d.

All of the above

Posted under C# programming

Answer: (b).3 and 4 Only

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. For the code snippet given below, which of the following statements are valid? public class MyContainer<T> where T: class, IComparable { //Insert code here } 1. Class...

Similar Questions

Discover Related MCQs

Q. Which of the following statements is valid about advantages of generics?

Q. The ‘ref’ keyword can be used with which among the following?

Q. To implement delegates, the necessary condition is?

Q. 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?

Q. To generate a simple notification for an object in runtime, the programming construct to be used for implementing this idea?

Q. Choose the incorrect statement among the following about the delegate?

Q. Which among the following is the correct statement about delegate declaration ?

delegate void del(int i);

Q. Which of the following is an incorrect statement about delegate?

Q. Which among the following differentiates a delegate in C#.NET from a conventional function pointer in other languages?

Q. Choose the incorrect statement about delegates?

Q. Which of the following statements is correct about a delegate?

Q. Choose the statements which makes delegate in C#.NET different from a normal class?

Q. Which of the following are the correct statements about delegates?

Q. Incorrect statements about delegates are?

Q. Select the modifiers which control the accessibility of the delegate:

Q. What is meant by the term generics?

Q. Are generics in C# are same as the generics in java and templates in C++?

Q. Choose the advantages of using generics?

Q. What does the following code block defines?

class Gen<T>
{
T ob;
}

Q. What does the following code set defines?

public Gen(T o)
{
ob = o;
}