41. Accessibility modifiers defined in a class are?
42. What will be the output of the following C# code snippet?
class Program
{
static void Main(string[] args)
{
int[] nums = {3 ,1 ,2 ,5 ,4};
var ltAvg = from n in nums
let x = nums.Average()
where n < x
select n;
Console.WriteLine("The average is " + nums.Average());
Console.ReadLine();
}
}
class Program
{
static void Main(string[] args)
{
int[] nums = {3 ,1 ,2 ,5 ,4};
var ltAvg = from n in nums
let x = nums.Average()
where n < x
select n;
Console.WriteLine("The average is " + nums.Average());
Console.ReadLine();
}
}
43. What is mutex?
44. Which of these constructors is used to create an empty String object?
45. Which among the following is a .NET namespace?
46. What will be the output of the following C# code snippet?
class Program
{
static void Main(string[] args)
{
String c = "Hello i love Csharp";
Boolean var;
var = c.StartsWith("hello");
Console.WriteLine(var);
Console.ReadLine();
}
}
class Program
{
static void Main(string[] args)
{
String c = "Hello i love Csharp";
Boolean var;
var = c.StartsWith("hello");
Console.WriteLine(var);
Console.ReadLine();
}
}
47. What will be the following C# code snippet specify?
class MyClass
{
char chrs = 'A' ;
public IEnumerator GetEnumerator()
{
for (int i = 20; i >=0; --i)
if (i == 10) yield break;
yield return (char)((chrs + i));
}
}
class Program
{
static void Main(string[] args)
{
MyClass mc = new MyClass();
foreach (char ch in mc)
Console.Write(ch + " ");
Console.WriteLine();
Console.ReadLine();
}
}
class MyClass
{
char chrs = 'A' ;
public IEnumerator GetEnumerator()
{
for (int i = 20; i >=0; --i)
if (i == 10) yield break;
yield return (char)((chrs + i));
}
}
class Program
{
static void Main(string[] args)
{
MyClass mc = new MyClass();
foreach (char ch in mc)
Console.Write(ch + " ");
Console.WriteLine();
Console.ReadLine();
}
}
48. What will be the output of the following C# code snippet?
class Program
{
static void Main(string[] args)
{
String s1 = "one";
String s2 = string.Concat(s1 + " " + "two");
Console.WriteLine(s2);
Console.ReadLine();
}
}
class Program
{
static void Main(string[] args)
{
String s1 = "one";
String s2 = string.Concat(s1 + " " + "two");
Console.WriteLine(s2);
Console.ReadLine();
}
}
49. What will be the output of the following C# code snippet?
class UnsafeCode
{
unsafe static void Main()
{
int* ptrs = stackalloc int[3];
ptrs[0] = 1;
ptrs[1] = 2;
ptrs[2] = 3;
for (int i = 2; i >= 0; --i)
{
ptrs[i] = ptrs[i]* 3;
ptrs[i] = ptrs[i] + 4;
Console.WriteLine(ptrs[i]);
}
Console.ReadLine();
}
}
class UnsafeCode
{
unsafe static void Main()
{
int* ptrs = stackalloc int[3];
ptrs[0] = 1;
ptrs[1] = 2;
ptrs[2] = 3;
for (int i = 2; i >= 0; --i)
{
ptrs[i] = ptrs[i]* 3;
ptrs[i] = ptrs[i] + 4;
Console.WriteLine(ptrs[i]);
}
Console.ReadLine();
}
}
50. Choose the base class for string() method.
Read More Section(Miscellaneous in C Sharp)
Each Section contains maximum 100 MCQs question on Miscellaneous in C Sharp. To get more questions visit other sections.