Arrays And Strings In C Sharp - Study Mode

[#111] What is the correct way to declare an array of strings with 5 elements in C#?
Correct Answer

(C) string[] names = new string[5]

[#112] How do you access the last element of an array named 'values' in C#?
Correct Answer

(B) values[values.Length - 1]

[#113] 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,'x00' }
for (int i = 0
i < b.Length
i++)
{
b[i] = b[i] + k[i]
Console.WriteLine( b[i] + " ")
}
}
Correct Answer

(D) 4, 6, 10, 12, 5

[#114] Which statement is correct about following c#.NET code? int[] a= {11, 3, 5, 9, 6}
Correct Answer

(C) 'a' is a reference to an object of a class that compiler drives from 'System.Array' class

[#115] 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])
}
}
Correct Answer

(D) 2, 34, 46, 88, 90