Exercise: Arrays
Questions for: Arrays
Which of the following is the correct way to obtain the number of elements present in the array given below?
int[] intMyArr = {25, 30, 45, 15, 60};
- intMyArr.GetMax;
- intMyArr.Highest(0);
- intMyArr.GetUpperBound(0);
- intMyArr.Length;
- intMyArr.GetMaxElements(0);
A:
1, 2
B:
3, 4
C:
3, 5
D:
1, 5
Answer: B
using System;
public class Test
{
public static void Main()
{
int[] intMyArr = { 25, 30, 45, 15, 60, 78, 99 };
Console.WriteLine(intMyArr.Length);
Console.WriteLine(intMyArr.GetUpperBound(0)+1);
}
}
/*
Output :
7
7
*/
Which of the following is the correct output of the C#.NET code snippet given below?
int[][] a = new int[2][];
a[0] = new int[4]{6, 1, 4, 3};
a[1] = new int[3]{9, 2, 7};
Console.WriteLine(a[1].GetUpperBound(0));
A:
3
B:
4
C:
7
D:
9
Answer: E
No answer description is available. Let's discuss.
Discuss About this Question.
Which of the following is the correct way to define and initialise an array of 4 integers?
-
int[] a = {25, 30, 40, 5}; -
int[] a; a = new int[3]; a[0] = 25; a[1] = 30; a[2] = 40; a[3] = 5; -
int[] a; a = new int{25, 30, 40, 5}; -
int[] a; a = new int[4]{25, 30, 40, 5}; -
int[] a; a = new int[4]; a[0] = 25; a[1] = 30; a[2] = 40; a[3] = 5;
A:
1, 2
B:
3, 4
C:
1, 4, 5
D:
2, 4, 5
Answer: C
No answer description is available. Let's discuss.
Discuss About this Question.
Which of the following statements is correct about the C#.NET code snippet given below?
int[] intMyArr = {11, 3, 5, 9, 4};
A:
intMyArr is a reference to an object of System.Array Class.
B:
intMyArr is a reference to an object of a class that the compiler derives from System.Array Class.
C:
intMyArr is a reference to an array of integers.
D:
intMyArr is a reference to an object created on the stack.
Answer: B
No answer description is available. Let's discuss.
Discuss About this Question.
Which of the following statements is correct about the array declaration given below?
int[][][] intMyArr = new int[2][][];
A:
intMyArr refers to a 2-D jagged array containing 2 rows.
B:
intMyArr refers to a 2-D jagged array containing 3 rows.
C:
intMyArr refers to a 3-D jagged array containing 2 2-D jagged arrays.
D:
intMyArr refers to a 3-D jagged array containing three 2-D jagged arrays.
Answer: C
No answer description is available. Let's discuss.
Discuss About this Question.
Ad Slot (Above Pagination)
Discuss About this Question.