Trắc Nghiệm C# - Bài 47
1-
|
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.
|
2-
|
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.
|
3-
|
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
|
4-
|
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 -
|
2
|
|
B -
|
3
|
|
C -
|
7
|
|
D -
|
9
|
5-
|
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
|
6-
|
What will be the output of the C#.NET code snippet given below?
namespace IndiabixConsoleApplication
{
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 ] + " ");
}
}
}
}
}
|
|
A -
|
0 0 34 34
|
|
B -
|
0 0 17 17
|
|
C -
|
0 0 0 0
|
|
D -
|
17 17 0 0
|
7-
|
Which of the following statements are true about the C#.NET code snippet given below?
String s1, s2;
s1 = "Hi";
s2 = "Hi";
- String objects cannot be created without using new.
- Only one object will get created.
- s1 and s2 both will refer to the same object.
- Two objects will get created, one pointed to by s1 and another pointed to by s2.
- s1 and s2 are references to the same object.
|
|
A -
|
1, 2, 4
|
|
B -
|
2, 3, 5
|
|
C -
|
3, 4
|
|
D -
|
2, 5
|
8-
|
Which of the following will be the correct output for the C#.NET code snippet given below?
String s1 = "ALL MEN ARE CREATED EQUAL";
String s2;
s2 = s1.Substring(12, 3);
Console.WriteLine(s2);
|
|
A -
|
ARE
|
|
B -
|
CRE
|
|
C -
|
CR
|
|
D -
|
REA
|
9-
|
Which of the following statements will correctly copy the contents of one string into another ?
|
|
A -
|
String s1 = "String"; String s2; s2 = s1;
|
|
B -
|
String s1 = "String" ; String s2; s2 = String.Concat(s1, s2);
|
|
C -
|
String s1 = "String"; String s2; s2 = String.Copy(s1);
|
|
D -
|
String s1 = "String"; String s2; s2 = s1.Replace();
|
10-
|
Which of the following will be the correct output for the C#.NET code snippet given below?
String s1 = "Nagpur";
String s2;
s2 = s1.Insert(6, "Mumbai");
Console.WriteLine(s2);
|
|
A -
|
Nagpur Mumbai
|
|
B -
|
Mumbai
|
|
C -
|
Nagpur
|
|
D -
|
NagpurMumbai
|
[Người đăng: Thành Lãm - ST]
|