Question
public class TestCompSciBits
{
public void TestSub<M> (M arg)
{
Console.Write(arg);
}
}
class MyProgram
{
static void Main(string[] args)
{
TestCompSciBits Bits = new TestCompSciBits();
Bits.TestSub("CompSciBits ");
Bits.TestSub(4.2f);
}
}
a.
Program will compile and on execution will print: CompSciBits 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.
Posted under C# programming
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 shown below, which of the following statements are valid?
Similar Questions
Discover Related MCQs
Q. Which of the following statements is valid about advantages of generics?
View solution
Q. The ‘ref’ keyword can be used with which among the following?
View solution
Q. To implement delegates, the necessary condition is?
View solution
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?
View solution
Q. To generate a simple notification for an object in runtime, the programming construct to be used for implementing this idea?
View solution
Q. Choose the incorrect statement among the following about the delegate?
View solution
Q. Which among the following is the correct statement about delegate declaration ?
delegate void del(int i);
View solution
Q. Which of the following is an incorrect statement about delegate?
View solution
Q. Which among the following differentiates a delegate in C#.NET from a conventional function pointer in other languages?
View solution
Q. Choose the incorrect statement about delegates?
View solution
Q. Which of the following statements is correct about a delegate?
View solution
Q. Choose the statements which makes delegate in C#.NET different from a normal class?
View solution
Q. Which of the following are the correct statements about delegates?
View solution
Q. Incorrect statements about delegates are?
View solution
Q. Select the modifiers which control the accessibility of the delegate:
View solution
Q. What is meant by the term generics?
View solution
Q. Are generics in C# are same as the generics in java and templates in C++?
View solution
Q. Choose the advantages of using generics?
View solution
Q. What does the following code block defines?
class Gen<T>
{
T ob;
}
View solution
Q. What does the following code set defines?
public Gen(T o)
{
ob = o;
}
View solution
Suggested Topics
Are you eager to expand your knowledge beyond C# programming? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!