Generics

Q1:
For the code snippet shown below, which of the following statements are valid?
public class TestAptitudeCrack
{
    public void TestSub<M> (M arg)
    {
        Console.Write(arg);
    }
}
class MyProgram
{
    static void Main(string[] args)
    {
        TestAptitudeCrack Aptitude = new TestAptitudeCrack();
        Aptitude.TestSub('AptitudeCrack ');
        Aptitude.TestSub(4.2f);
    }
}

A
Program will compile and on execution will print: AptitudeCrack 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.

ANS:A -

Program will compile and on execution will print: AptitudeCrack 4.2

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.