Delegates And Events In C Sharp - Study Mode

[#56] What does the following C# code block defines? class Gen<T>
{
T ob
}
Correct Answer

(A) Generics class declaration

[#57] Which of the following is the correct way to call the subroutine function abc() of the given class in the following C# code? class csharp
{
void abc()
{
console.writeline("A:Just do it!")
}
}
Correct Answer

(B) delegate void del() del d csharp s = new csharp() d = new del(ref s.abc) d()

[#58] Which among the following is the correct statement about delegate declaration? delegate void del(int i)
Correct Answer

(D) all of the mentioned

[#59] What will be the output of the following C# code snippet? public class Generic<T>
{
Stack<T> stk = new Stack<T>()
public void push(T obj)
{
stk.Push(obj)
}
public T pop()
{
T obj = stk.Pop()
return obj
}
}
class Program
{
static void Main(string[] args)
{
Generic<string> g = new Generic<string>()
g.push(30)
Console.WriteLine(g.pop())
Console.ReadLine()
}
}
Correct Answer

(B) 30

[#60] Which of the following statements are valid in the following C# code snippet? public class Generic<T>
{
public T Field
public void testSub()
{
T i = Field + 1
}
}
class Program
{
static void Main(string[] args)
{
Genericlt
int>g = new Genericlt
int>()
g.testSub()
}
}
Correct Answer

(D) compile time error