Generics

Q1:
For the code snippet given below, which of the following statements are valid?
public class MyContainer<T> where T: IComparabte
{
    // Insert code here
}
  1. Class MyContainer requires that it's type argument must implement IComparabte interface.
  2. Type argument of class MyContainer must be IComparabte.
  3. Compiler will report an error for this block of code.
  4. This requirement on type argument is called as constraint.

A 1 and 2 Only

B 3 and 4 Only

C 2 and 3 Only

D All of the above

E None of the above

ANS:B - 3 and 4 Only

No answer description is available. Let's discuss.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.