Miscellaneous In C Sharp - Study Mode

[#136] What will be the output of the following C# code snippet? class Program
{
static void Main(string[] args)
{
String s1 = "Hello i love Csharp"
StringBuilder s2 = new StringBuilder(s1)
Console.WriteLine(s1.Equals(s2))
Console.ReadLine()
}
}
Correct Answer

(B) False

[#137] A HashTable t maintains a collection of names of states and capital city of each state. Which among the following finds out whether "New delhi" state is present in the collection or not?
Correct Answer

(B) t.ContainsKey("New delhi")

[#138] What does the yield return statement specify in the following C# code snippet? public System.Collections.IEnumerator GetEnumerator()
{
foreach (char ch in chrs)
yield return ch
}
Correct Answer

(B) returns the next object in the collection

[#139] What will be the output of the following C# code snippet? class Program
{
static void Main(string[] args)
{
int y = (int)Math.Max(4,2)
int z = (int)Math.Pow(y, 2)
Console.WriteLine(z)
Console.ReadLine()
}
}
Correct Answer

(C) 16

[#140] What will be the output of the following C# code snippet? class UnsafeCode
{
unsafe static void Main()
{
int m = 10
int *mptr = &m
int **ptr = &mptr
int n = 20
int *nptr = &n
int **prt = &nptr
m = **prt + *nptr
n = *mptr* **prt
Console.WriteLine(n + " " + m)
Console.ReadLine()
}
}
Correct Answer

(C) 800 40