31. Choose the method defined by MemberInfo.
32. Which among the following is the correct statement about the using statement used in C#.NET?
33. Which of these methods of class String is used to extract a substring from a String object?
34. What will be the output of the following C# code snippet?
class Program
{
static void Main(string[] args)
{
char []chars = {'a', 'b', 'c'};
String s = new String(chars);
Console.WriteLine(s);
Console.ReadLine();
}
}
class Program
{
static void Main(string[] args)
{
char []chars = {'a', 'b', 'c'};
String s = new String(chars);
Console.WriteLine(s);
Console.ReadLine();
}
}
35. If ListBox is the class of System.Windows.Forms namespace. Then, the correct way to create an object of ListBox class is?
36. What will be the output of the following C# code snippet?
unsafe static void Main()
{
int a = 5;
int b = 5;
int c = 5;
int*[] ptr = new int* [3];
ptr[0] = &a;
ptr[1] = &b;
ptr[2] = &c;
for (a = 0; a < 3; a++)
{
c += *ptr[a];
Console.WriteLine(c);
}
Console.ReadLine();
}
unsafe static void Main()
{
int a = 5;
int b = 5;
int c = 5;
int*[] ptr = new int* [3];
ptr[0] = &a;
ptr[1] = &b;
ptr[2] = &c;
for (a = 0; a < 3; a++)
{
c += *ptr[a];
Console.WriteLine(c);
}
Console.ReadLine();
}
37. What will be the output of the following C# code snippet?
static void Main(string[] args)
{
string s1 = "Hello" + "c" + "Sharp";
Console.WriteLine(s1);
Console.ReadLine();
}
static void Main(string[] args)
{
string s1 = "Hello" + "c" + "Sharp";
Console.WriteLine(s1);
Console.ReadLine();
}
38. Which of these methods of class String is used to check whether a given string starts with a particular substring or not?
39. What will be the output of the following C# code snippet?
class static_out
{
public static int x;
public static int y;
public int add(int a, int b)
{
x = a + b;
y = x + b;
return 0;
}
}
class Program
{
static void Main(string[] args)
{
static_out obj1 = new static_out();
static_out obj2 = new static_out();
int a = 2;
obj1.add(a, a + 1);
obj2.add(5, a);
Console.WriteLine(static_out.x + " " + static_out.y );
Console.ReadLine();
}
}
class static_out
{
public static int x;
public static int y;
public int add(int a, int b)
{
x = a + b;
y = x + b;
return 0;
}
}
class Program
{
static void Main(string[] args)
{
static_out obj1 = new static_out();
static_out obj2 = new static_out();
int a = 2;
obj1.add(a, a + 1);
obj2.add(5, a);
Console.WriteLine(static_out.x + " " + static_out.y );
Console.ReadLine();
}
}
40. What will be the output of the following C# code snippet?
class MyClass
{
char ch = 'A';
int e = 4;
int k = 9;
int z = 6;
public IEnumerator GetEnumerator()
{
for (int i = 0; i < 26; i++)
{
if (i == e*k /z) yield break;
yield return (int)(ch + i);
}
}
}
class Program
{
static void Main(string[] args)
{
MyClass mc = new MyClass();
foreach(int ch in mc)
Console.Write(ch + " ");
Console.WriteLine();
Console.ReadLine();
}
}
class MyClass
{
char ch = 'A';
int e = 4;
int k = 9;
int z = 6;
public IEnumerator GetEnumerator()
{
for (int i = 0; i < 26; i++)
{
if (i == e*k /z) yield break;
yield return (int)(ch + i);
}
}
}
class Program
{
static void Main(string[] args)
{
MyClass mc = new MyClass();
foreach(int ch in mc)
Console.Write(ch + " ");
Console.WriteLine();
Console.ReadLine();
}
}
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.