11. What will be the output of the following C# code?
static void Main(string[] args)
{
int [] a = {1, 2, 3, 4, 5};
fun(a);
Console.ReadLine();
}
static void fun(params int[] b )
{
int[] k = { 3, 4, 7, 8,'\0' };
for (int i = 0; i < b.Length; i++)
{
b[i] = b[i] + k[i] ;
Console.WriteLine( b[i] + " ");
}
}
static void Main(string[] args)
{
int [] a = {1, 2, 3, 4, 5};
fun(a);
Console.ReadLine();
}
static void fun(params int[] b )
{
int[] k = { 3, 4, 7, 8,'\0' };
for (int i = 0; i < b.Length; i++)
{
b[i] = b[i] + k[i] ;
Console.WriteLine( b[i] + " ");
}
}
12. Which of the following string() method are used to compare two strings with each other?
13. Which statement is correct about following c#.NET code?
int[] a= {11, 3, 5, 9, 6};
int[] a= {11, 3, 5, 9, 6};
14. What will be the output of the following C# code?
static void Main(string[] args)
{
int[] a = { 2, 21, 34, 46, 85, 88, 90};
fun(a);
Console.WriteLine(a + " ");
Console.ReadLine();
}
static void fun(params int [] b )
{
int [] c = { 1, 2, 3, 4, 5, 6, 7};
int i ;
for (i = 0 ;i < b.Length ;i++)
if (b[i] % 2 == 0)
{
c[i] = b[i];
}
Console.WriteLine("even numbers are:");
for (i = 0 ;i <= b.Length ;i++)
{
Console.WriteLine(c[i]);
}
}
static void Main(string[] args)
{
int[] a = { 2, 21, 34, 46, 85, 88, 90};
fun(a);
Console.WriteLine(a + " ");
Console.ReadLine();
}
static void fun(params int [] b )
{
int [] c = { 1, 2, 3, 4, 5, 6, 7};
int i ;
for (i = 0 ;i < b.Length ;i++)
if (b[i] % 2 == 0)
{
c[i] = b[i];
}
Console.WriteLine("even numbers are:");
for (i = 0 ;i <= b.Length ;i++)
{
Console.WriteLine(c[i]);
}
}
15. How to print \ on the screen?
16. What will be the output of the following C# code?
static void Main(string[] args)
{
int a = 5;
int b = 0, c = 0;
method (a, ref b, ref c);
Console.WriteLine(b + " " + c);
Console.ReadLine();
}
static int method(int x, int p, ref int k)
{
p = x + x * x;
k = x * x + p;
return 0;
}
static void Main(string[] args)
{
int a = 5;
int b = 0, c = 0;
method (a, ref b, ref c);
Console.WriteLine(b + " " + c);
Console.ReadLine();
}
static int method(int x, int p, ref int k)
{
p = x + x * x;
k = x * x + p;
return 0;
}
17. Which statement is/are correct?
18. Which of these methods of class String is used to compare two String objects for their equality?
19. Which of these is used to access members of class before the object of that class is created?
20. What is the value returned by function compareTo() if the invoking string is less than the string compared?
Read More Section(Arrays and Strings in C Sharp)
Each Section contains maximum 100 MCQs question on Arrays and Strings in C Sharp. To get more questions visit other sections.