In: Computer Science
1 of 10
When declaring a jagged array, all dimensions must have the same type.
True | |
False |
Question
2 of 10
What is the maximum number of dimensions you can declare for an array in C#?
3 | |
10 | |
5 | |
There is no maximum. |
Question
3 of 10
When you declare a two-dimensional array, you place two numbers within square brackets. What does the first number represent?
Class | |
Index | |
Column | |
Row |
Question
4 of 10
When declaring a multidimensional array, all dimensions must have the same type.
True | |
False |
Question
5 of 10
Given the code below, the variables "student1" and "student2" refer to the same memory location.
string student1 = "Student";
string student2 = "Student";
True | |
False |
Question
6 of 10
The code below declares a jagged array.
int[][] jaggedArray = new int[2][];
jaggedArray[0] = new int[20];
jaggedArray[1] = new int[10];
int[0,10] = 95; | |
int[0][10] = 95; | |
int[1,11] = 95; | |
int[1][11] = 95; |
Question
7 of 10
Given the code below, what is the output?
string student = " Student";
Console.WriteLine(student.Length)
7 | |
Run-time exception | |
Compile-time exception | |
8 |
Question
8 of 10
Given the code below, what is the output?
string student1 = "Student";
string student2 = "Student";
if(student1 == student2)
{
Console.WriteLine("True");
}
else
{
Console.WriteLine("False");
}
True | |
False |
Question
9 of 10
Select the output for the statement below.
int[,] examArray = new int[30, 6];
Console.WriteLine(examArray.GetLength(2));
A compilation error generates. | |
A run-time error generates. | |
6 | |
30 |
Question
10 of 10
You can use multidimensional arrays to store a different number of columns for certain rows.
True | |
False |
1) TRUE
jagged array means array of arrays and it may contain different dimensions but all must have same type
2) There is no maximum.
3) first number inside square brackets represents the rows
second number represents the columns
4) TRUE
In multi dimentional array all dimensions must be of same type.
5) TRUE
both student1 and student2 refers to same memory location.
6) int[][] jaggedArray = new int[2][];
this code will create jagged array with 2 rows
jaggedArray[0] = new int[20]; //this means first row will contain 20 elements
jaggedArray[1] = new int[10]; // second row will contain 10 elements
accessing& assigning array elements
jaggedArray[0][10]=95; -----> is the correct way of assigning
7) it gives output as 8
since student has 7 characters and there is space present before s letter , so totally 8
8) TRUE
since both objects refers to same memory location , therefore both are equal
9) Compilation error
it will give indexOutOfRange exception since the given array is 2-D i.e 0,1 .... but in getLength() it calls for 2 instead of 0 or 1.
10) TRUE
ex : int[][] arr=new int[5][10];
here arr has 5 rows and 10 columns ---> so we can store different no.of columns on certain rows.