42. Incorrect statements about delegates are?
43. What does the following C# code block defines?
class Gen<T>
{
T ob;
}
class Gen<T>
{
T ob;
}44. 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!");
}
}
class csharp
{
void abc()
{
console.writeline("A:Just do it!");
}
}45. Which among the following is the correct statement about delegate declaration?
delegate void del(int i);
delegate void del(int i);46. Are generics in C# are same as the generics in java and templates in C++?
47. 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();
}
}
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();
}
}48. Which of the given statements are valid about generics in .NET Framework?
49. 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();
}
}
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();
}
}50. Choose the correct way to call subroutine fun() of the sample class?
class a
{
public void x(int p, double k)
{
Console.WriteLine("k : csharp!");
}
}
class a
{
public void x(int p, double k)
{
Console.WriteLine("k : csharp!");
}
}