1) There are following options are given below, which is correct way to declare an array with 2 rows and 3 columns?
- int arr[2][3] = new int[2][3];
- int arr[2,3] = new int[2,3];
- int [2,3]arr = new int[2,3];
- int [2,3]arr = new [2,3]int;
Correct answer: 3
int [2,3]arr = new int[2,3];
int [2,3]arr = new int[2,3]; - correct way to declare an array with 2 rows and 3 columns.
2) Can we create 4-dimensional arrays in C#.NET?
- Yes
- No
Correct answer: 1
Yes
Yes, we can create 4-dimensional arrays in C#.NET.
3) What is the correct output of given code snippets?
static void Main(string[] args)
{
int[, , ,] ARR = new int[2, 2, 2, 2];
Console.WriteLine(ARR.Length);
}
- 8
- 16
- 32
- Syntax Error
Correct answer: 2
16
The output of the above code will be 16 = (2 x 2 x 2 x 2 =16).
4) What is the correct output of given code snippets?
static void Main(string[] args)
{
string[] S = new string{ "XXXX", "YYYY" };
Console.WriteLine(S[0] + " " + S[1]);
}
- XXXX YYYY
- Syntax Error
- xxxx yyyy
- Runtime Exception
Correct answer: 2
Syntax Error
The above code will generate a syntax error because the declaration of an array of strings is not correct.
5) What is the correct output of given code snippets?
static void Main(string[] args)
{
string[] S = new string[2]{ "XXXX", "YYYY" };
Console.WriteLine(S[0] + " " + S[1]);
}
- XXXX YYYY
- Syntax Error
- xxxx yyyy
- Runtime Exception
Correct answer: 1
XXXX YYYY
The above code will print "XXXX YYYY" on console screen.