Miscellaneous In C Sharp - Study Mode

[#146] Choose the correct statements for the following C# code? public System.Collections.IEnumerator GetEnumerator()
{
foreach (char ch in chrs)
yield return ch
}
Correct Answer

(D) All of the mentioned

[#147] Which among the given is not a correct way to call the method Issue() defined in the following C# code snippet? class Book
{
public void issue()
{
/* code */
}
}
class Journel
{
public void issue()
{
/* code */
}
}
Correct Answer

(B) Book b = new Book() b.issue()

[#148] What will be the output of the following C# code snippet? class UnsafeCode
{
static void Main()
{
int? count = null
int? result = null
int incr = 10
result = count + incr
if (result.HasValue)
Console.WriteLine("result has this value: " + result.Value)
else
Console.WriteLine("result has no value")
Console.ReadLine()
}
}
Correct Answer

(C) Result has no value

[#149] What will be the output of the following C# code snippet? #define DEBUG
#undef DEBUG
using System
using System.Collections.Generic
using System.Linq
using System.Text
using System.Threading.Tasks
namespace ConsoleApplication13
{
class Program
{
static void Main(string[] args)
{
#if (DEBUG)
Console.WriteLine("DEBUG is defined")
#elif (!DEBUG && MYTEST)
Console.WriteLine("MYTEST is defined")
#elif (DEBUG && MYTEST)
Console.WriteLine("DEBUG and MYTEST are defined")
#else
Console.WriteLine("DEBUG and MYTEST are not defined")
#endif
Console.ReadLine()
}
}
}
Correct Answer

(B) DEBUG and MYTEST are not defined

[#150] What will be the output of the following C# code snippet? class UnsafeCode
{
struct MyStruct
{
public int a
public int b
public int Sum()
{
return a * b
}
}
unsafe static void Main()
{
MyStruct o = new MyStruct()
MyStruct* p
p = &o
p->a = 10
p->b = 20
Console.WriteLine("Value is " + p->Sum())
Console.ReadLine()
}
Correct Answer

(C) 200