Delegates And Events In C Sharp - Study Mode

[#61] 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!")
}
}
Correct Answer

(B) delegate void del(int p, double k) del d x s = new x() d = new del(ref s.x) d(8, 2.2f)
(F) delegate void del(int p, double k) del d x s = new x() d = new del(ref s.x) d(8, 2.2f)

[#62] What will be the output of the following C# code? {
delegate string f(string str)
class sample
{
public static string fun(string a)
{
return a.Replace('k', 'o')
}
}
class Program
{
static void Main(string[] args)
{
f str1 = new f(sample.fun)
string str = str1("Test Ykur C#.NET Skills")
Console.WriteLine(str)
Console.ReadLine()
}
}
}
Correct Answer

(C) Test Your C#.NET Skills

[#63] 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<int> g = new Generic<int>()
g.push("Csharp")
Console.WriteLine(g.pop())
Console.ReadLine()
}
}
Correct Answer

(B) Csharp
(F) Csharp

[#64] In the following C# code, which statements are perfectly valid? public class Csharp
{
public void subject<S>(S arg)
{
Console.WriteLine(arg)
}
}
class Program
{
static Void Main(string[] args)
{
Csharp c = new Csharp()
c.subject("hi")
c.subject(20)
}
}
Correct Answer

(C) Code runs successfully and prints required output

[#65] 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("C++")
Console.WriteLine(g.pop() + " ")
Generic<int> g1 = new Generic<int>()
g1.push(20)
Console.WriteLine(g1.pop())
Console.ReadLine()
}
}
Correct Answer

(C) C++ 20