Please Help me with these C# questions Thanks 1)When an array is sent to a metho
ID: 3695407 • Letter: P
Question
Please Help me with these C# questions
Thanks
1)When an array is sent to a method as an argument, if the method changes one or more of the elements, the changes are made to the actual data.
A)True
B)False
2)Arrays can be used as fields or instance variables in classes; and, arrays of objects can be declared.
A)True
B)False
3)int [ ] anArray = new int[24];
For the above declaration, 25 cells are set aside for the array since the first element is referenced by index 0.
A)True
B) False
4)int [ ] score = {86, 66, 76, 92, 95, 88};
for (int i = score.Length-1; i > -1; i--)
{
total += score[i];
}
Using the declaration above for score, what is added to total during the first iteration?
A)0
B)88
C)86, 66, 76, 92 and 95
D)unknown, because i is not initialized
5) If an array is to be sent to a method, which of the following is a valid heading for a method?
A)void DisplayOutput(double [ ] anArray)
B)void DisplayOutput(double [10 ] anArray)
C)void DisplayOutput(double anArray)
D)void DisplayOutput(double anArray [10])
6)When two or more arrays have a relationship such that you are able to use the same subscript or index to refer to related elements in the arrays, you have ____ arrays.
A)parallel
B)two dimensional
C)dynamic
D)related
7)Which loop structure can be used to change the contents of the array?
A)for
B)foreach
C)loop
D)if / else
8)Given an array declaration of int anArray[1000], which of the following would be a valid heading for a method that sends the array in as a parameter?
A)void DisplayContents(int anArray)
B)void DisplayContents(int anArray[])
C)void DisplayContents(int [ ] anArray)
D)void DisplayContents(anArray[1000])
9)int [ ] anArray = new int [10];
int [ ] anotherArray = {6, 7, 4, 5, 6, 2, 3, 5, 9, 1};
anotherArray.Length returns ____.
A)9
B)10
C)11
D)20
10)int [ ] anArray = new int [10];
int [ ] anotherArray = {6, 7, 4, 5, 6, 2, 3, 5, 9, 1};
Which of the following would copy all of the elements from anotherArray to anArray?
A)Array.Copy(anotherArray, 0, anArray, 0, 10);
B)Array.Copy(anotherArray, anArray)
C)anArray = anotherArray
D)all of the above
Explanation / Answer
1. True.
2. True.
3. False.
4. C. 88.
5. A.
6. A.
7. A.
8. C.
9. B.
10.