C# Arrays Aptitude Questions and Answers | Set 5

C# Arrays Aptitude Questions | Set 5: This section contains aptitude questions and answers on C# Arrays.
Submitted by Nidhi, on April 01, 2020

1) There are following options are given below, which is correct way to declare an array with 2 rows and 3 columns?
  1. int arr[2][3] = new int[2][3];
  2. int arr[2,3] = new int[2,3];
  3. int [2,3]arr = new int[2,3];
  4. int [2,3]arr = new [2,3]int;

2) Can we create 4-dimensional arrays in C#.NET?
  1. Yes
  2. No

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);
}
  1. 8
  2. 16
  3. 32
  4. Syntax Error

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]);
}
  1. XXXX YYYY
  2. Syntax Error
  3. xxxx yyyy
  4. Runtime Exception

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]);
}
  1. XXXX YYYY
  2. Syntax Error
  3. xxxx yyyy
  4. Runtime Exception






Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.