C# Arrays Aptitude Questions and Answers | Set 4

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

1) What is the correct output of given code snippets?
static void Main(string[] args) { int[] ARR = {1,2,3,4,5}; Console.WriteLine(ARR.GetLength(1)); }
  1. 5
  2. 6
  3. Syntax Error
  4. Runtime Error

2) What is the correct output of given code snippets?
static void Main(string[] args) { int[] ARR = {1,2,3,4,5}; Console.WriteLine(ARR.GetLength(0)); }
  1. 5
  2. 6
  3. Syntax Error
  4. Runtime Error

3) What is the correct output of given code snippets?
static void Main(string[] args) { int[] ARR = {1,2,3,4,5}; Console.WriteLine(ARR.MAX()); }
  1. 5
  2. 6
  3. Syntax Error
  4. Runtime Error

4) What is the correct output of given code snippets?
static void Main(string[] args) { int[] ARR = {1,2,3,4,5}; int X = 0; int i = 0; X = ARR[0]; for (i = 1; i < ARR.Length; i++) { if (X < ARR[i]) X = ARR[i]; } Console.WriteLine(X); }
  1. 5
  2. 6
  3. Syntax Error
  4. Runtime Error

5) What is the correct output of given code snippets?
static void Main(string[] args) { int[,] ARR = {{1,2},{3,4}}; Console.WriteLine(ARR.GetLength(1)); }
  1. 5
  2. 2
  3. Syntax Error
  4. Runtime Error



Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

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