Home / C# Programming / Generics :: Discussion

Discussion :: Generics

  1. For the code snippet shown below, which of the following statements are valid?

    public class Testfreshergate
    {  
         public void TestSub (M arg)  
         {       
            Console.Write(arg);   
         }
      }
      class MyProgram 
      {   
         static void Main(string[] args)  
         {       
             Testfreshergate gate = new Test();
             gate.TestSub(" ");
             gate.TestSub(4.2f);
         }
      }
       
    

  2. A.

    Program will compile and on execution will print: freshergate 4.2

    B.

    A non generic class Hello cannot have generic subroutine.

    C.

    Compiler will generate an error.

    D.

    Program will generate a run-time exception.

    E.

    None of the above.

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    No answer description available for this question.


Be The First To Comment