Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Arrays Questions
C#.NET — Consider the declaration: int[, ] intMyArr = { {7, 1, 3}, {2, 9, 6} }; Which statements about intMyArr are correct?
C#.NET — For the declaration below, what does intMyArr represent? int[][][] intMyArr = new int[2][][];
C#.NET — Complete the foreach so that all elements of the jagged array are printed: int[][] a = new int[2][]; a[0] = new int[4] { 6, 1, 4, 3 }; a[1] = new int[3] { 9, 2, 7 }; foreach (int[] i in a) { /* Add loop here */ Console.Write(j + " "); Console.WriteLine(); }
C#.NET — Which declarations correctly define a 2×3 rectangular array?
C#.NET — Array initialization of 4 integers: identify all syntactically correct ways (size and values must be 25, 30, 40, 5). Consider the following five code fragments (numbered 1–5). Which ones correctly define and initialize an array of exactly four integers with values 25, 30, 40, and 5, without indexing errors? 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;
C#.NET — Multidimensional arrays: compute .Length for a 3×2×3 array. Given: int[ , , ] a = new int[3, 2, 3]; Console.WriteLine(a.Length); What value is printed?
C#.NET — Jagged arrays: determine which statements are correct for the following code. Code: int[][] intMyArr = new int[2][]; intMyArr[0] = new int[4]{6, 1, 4, 3}; intMyArr[1] = new int[3]{9, 2, 7}; Which statements are true? intMyArr is a reference to a 2-D jagged array. The two rows of intMyArr are stored in adjacent memory locations. intMyArr[0] refers to the 0th 1-D array and intMyArr[1] refers to the 1st 1-D array. intMyArr refers directly to intMyArr[0] and intMyArr[1]. intMyArr refers to intMyArr[1] and intMyArr[2].
C#.NET — What does the declaration below represent? Choose the correct statements. Code: int[] intMyArr = {11, 3, 5, 9, 4}; Which are true? intMyArr is a reference to an object of System.Array. intMyArr is a reference to an object of a class that the compiler derives from System.Array. intMyArr is a reference to an array of integers. intMyArr is a reference to an object created on the stack. intMyArr is a reference to an array created on the stack.
C#.NET — “Resizing” an array variable from 5 to 10 elements: select the correct approach. If a is an array of 5 integers, choose the correct way to make a refer to a 10-element array (ignoring data preservation).
C#.NET — Pick the correct fact about arrays: rank, length, default values, and sorting.
C#.NET — Arrays: storage location and type hierarchy for int[] a = {11, 3, 5, 9, 4}. Which statements are true? The array elements are created on the stack. The reference variable a is created on the stack (as a local). The array elements are created on the heap. Declaring the array creates a new array class derived from System.Array. Whether the elements are on the stack or heap depends on the array size.
C#.NET — Jagged array bounds: evaluate GetUpperBound on the second inner array. Code: 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));
C#.NET — Trace nested loops and 2-D array assignments to predict output. Program: namespace CuriousTabConsoleApplication { class SampleProgram { static void Main(string[] args) { int i, j; int[ , ] arr = new int[2, 2]; for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { arr[i, j] = i * 17 + i * 17; Console.Write(arr[i, j] + " "); } } } } }
C#.NET — Arrays in .NET: rectangular vs jagged, adjacency, and System.Array methods. Which statements are correct? Arrays can be rectangular or jagged. Rectangular arrays have “similar rows” stored in adjacent memory locations. Jagged arrays do not have access to methods of System.Array. Rectangular arrays do not have access to methods of System.Array. Jagged arrays have dissimilar row lengths and rows are not stored adjacently like a single rectangular block.
C#.NET arrays — Which of the following is the correct way to obtain the total number of elements in the array? int[] intMyArr = { 25, 30, 45, 15, 60 }; Consider these candidates: 1) intMyArr.GetMax 2) intMyArr.Highest(0) 3) intMyArr.GetUpperBound(0) 4) intMyArr.Length 5) intMyArr.GetMaxElements(0)