adplus-dvertising
frame-decoration

Question

Which statement is valid for the given snippet of code:
public class Generic<T>
 {
     public T Field;
 }
 class Program
 {
     static void Main(string[] args)
     {
         Generic<int> g2 = new Generic<int>();
         Generic<int> g3 = new Generic<int>();
         g2.Field = 8;
         g3.Field = 4;
         if (g2.Field % g3.Field == 0)
         {
             Console.WriteLine("A");
         }
         else
         Console.WriteLine("Prints nothing:");
         Console.ReadLine();
     }
 }

a.

Compile time error

b.

A

c.

Run time error

d.

Code runs successfully but prints nothing

Answer: (b).A

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Which statement is valid for the given snippet of code:

Similar Questions

Discover Related MCQs

Q. Which of given statements are valid about generics in .NET Framework?

Q. Which of these type parameters is used for generic methods to return and accept any type of object?

Q. Which of these is a correct way of defining generic method?

Q. Which among the given classes is present in System.Collection.Generic.namespace?

Q. Select the type argument of an open constructed type?

Q. What does the following code set defines?

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

Q. What does the following code block defines?

class Gen<T>
{
T ob;
}

Q. Choose the advantages of using generics?

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

Q. What is meant by the term generics?

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

Q. Incorrect statements about delegates are?

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

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

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

Q. Choose the incorrect statement about delegates?

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

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

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

delegate void del(int i);

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