21. Among the given pointers which of the following cannot be incremented?
22. What will be the output of given code snippet?
class Program
{
static void Main(string[] args)
{
char []chars = {'a', 'b', 'c'};
String s = new String(chars);
String s1 = "abcd";
int len1 = s1.Length;
int len2 = s.Length;
Console.WriteLine(len1 + " " + len2);
Console.ReadLine();
}
}
class Program
{
static void Main(string[] args)
{
char []chars = {'a', 'b', 'c'};
String s = new String(chars);
String s1 = "abcd";
int len1 = s1.Length;
int len2 = s.Length;
Console.WriteLine(len1 + " " + len2);
Console.ReadLine();
}
}
23. Which of the following statements are incorrect?
24. 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--)
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--)
Console.WriteLine(ptrs[i]);
Console.ReadLine();
}
}
25. What is meant by preprocessor directive in C#.NET?
26. Pointer variable is used to hold the . . . . . . . . of the variable.
27. What will be the output of the following C# code snippet?
static void Main(string[] args)
{
string s1 = " Ixg";
string s2 = s1.Insert(3,"i");
string s3 = s2.Insert(5, "o");
for (int i = 0; i < s3.Length; i++)
Console.WriteLine(s3[i]);
Console.ReadLine();
}
static void Main(string[] args)
{
string s1 = " Ixg";
string s2 = s1.Insert(3,"i");
string s3 = s2.Insert(5, "o");
for (int i = 0; i < s3.Length; i++)
Console.WriteLine(s3[i]);
Console.ReadLine();
}
28. Which of these access specifiers must be used for class so that it can be inherited by another subclass?
29. Which of these statements is incorrect?
30. What will be the output of the following C# code snippet?
class UnsafeCode
{
unsafe static void Main()
{
string str = "this is a test";
fixed (char* p = str)
{
for (int i = str.Length-1 ;p[i] != 0 ;i--)
Console.Write(p[i]);
}
Console.ReadLine();
}
}
class UnsafeCode
{
unsafe static void Main()
{
string str = "this is a test";
fixed (char* p = str)
{
for (int i = str.Length-1 ;p[i] != 0 ;i--)
Console.Write(p[i]);
}
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.