QUESTION 1 Using the following declarations and a member of the Array class, int
ID: 3748242 • Letter: Q
Question
QUESTION 1
Using the following declarations and a member of the Array class,
int [ ] bArray = new int [10];
int location;
Using a method in the Array class, write a statement that would change the order of the elements in the bArray array. The contents of the first cell should hold what was in the last cell. The second cell should hold what was in the next to last cell.
__________________________
HINT: You must write the full statement which includes a call to a method in the Array class.
1 points
QUESTION 2
Using the following declaration:
int [ ] anArray = {34, 55, 67, 89, 99};
WriteLine(anArray[1] + 100);
a call to the WriteLine( ) method would display ____________,
1 points
QUESTION 3
Using the following declarations,
int counter = 0;
double val;
double [ ] bArray = new double [10];
To display the contents of bArray, show what the foreach loop control construct would resemble.
______________
HINT: Write the first line of the loop - the line that has the foreach on it. You are not writing the body...just the loop control statement.
1 points
QUESTION 4
Using the following declaration:
int [ ] anArray = {34, 55, 67, 89, 99};
WriteLine(anArray[2]);
a call to the WriteLine( ) method would display ____________,
1 points
QUESTION 5
What is returned by the method named result shown below?
int result(int[ ] anArray, int num)
{
int i, r;
for (r = 0, i = 1; i < num; ++i)
if (anArray[i] > anArray [r] )
r = i;
return (r);
}
the index of the largest of the first num elements of array anArray
the value of the largest of the first num elements of array anArray
the index of the smallest of the first num elements of array anArray
the value of the smallest of the first num elements of array anArray
the index of the last element greater than its predecessor within the first num elements of array anArray
1 points
QUESTION 6
_____________ would create an array declaration to hold the names of five font strings. Use font as your identifier. HINT: Your declaration must be syntactically correct, complete with an ending semicolon.
1 points
QUESTION 7
What is the effect of the following program segment?
int[ ] anArray = new int[50];
int i, j, temp;
string inValue;
for (i = 0; i < 50; ++i)
{
Write("Enter Value");
inValue = ReadLine( );
anArray[i] = int.Parse(inValue);
}
temp = 0;
for (i = 1; i < 50; ++i)
if (anArray[i] < anArray[0])
++temp;
arranges the elements of array anArray in ascending order
counts the number of elements of array anArray less than its initial element
reverses the numbers stored in the array
puts the largest value in the last array position
none of the above correct
1 points
QUESTION 8
Using the following declaration:
int [ ] anArray = {34, 55, 67, 89, 99};
WriteLine(anArray[anArray.Length 2]);
a call to the WriteLine( ) method would display ____________,
1 points
QUESTION 9
Assume you have a method heading that reads
public static void DoSomething (int [ ] temp)
A call to invoke the method sending in the array would look like:
______________________________________
HINT: Your declaration must be syntactically correct, complete with an ending semicolon.
1 points
QUESTION 10
Using the following declaration:
int [ ] anArray = {34, 55, 67, 89, 99};
WriteLine(anArray[2 + 1] * anArray[0]);
a call to the WriteLine( ) method would display ____________,
1 points
QUESTION 11
Using the following declaration:
int [ ] anArray = {34, 55, 67, 89, 99};
WriteLine(anArray.Length);
a call to the WriteLine( ) method would display _____________.
1 points
QUESTION 12
Using just the following declarations,
int counter = 0;
int val;
int [ ] bArray = new int [10];
Write the body of the for loop that could be used to increment each element in bArray by 5. The for loop might loop like:
for (counter = 0; counter < bArray.Length; counter++)
__________________
HINT: You are not writing the control structure, just the body of the loop where counter will be the index used with the bArray.
1 points
QUESTION 13
_____________ would create an array declaration and do a compile-time initialization to hold the 5 most common single character middle initials. The most common are A, N, R, S and T. Use middleInitial
as your identifier. HINT: Your declaration must be syntactically correct, complete with an ending semicolon.
1 points
QUESTION 14
Using the following declarations and a member of the Array class,
int [ ] bArray = new int [10];
int location;
Using a method in the Array class, write a statement that would order the values in the bArray array in ascending order.
___________________
HINT: You must write the full statement which includes a call to a method in the Array class.
1 points
QUESTION 15
Using the following declarations and a member of the Array class,
int [ ] bArray = new int [10];
int location;
Using a method of the Array class, write an assignment statement that would return the index in the bArray array where 14 is stored.
__________________________
HINT: You must write the full assignment statement which includes a call to a method in the Array class.
the index of the largest of the first num elements of array anArray
the value of the largest of the first num elements of array anArray
the index of the smallest of the first num elements of array anArray
the value of the smallest of the first num elements of array anArray
the index of the last element greater than its predecessor within the first num elements of array anArray
Explanation / Answer
Solutions:
Solution 1:
Array.reverse(bArray);
reverse is a method in Array class which takes in the array and reverses it.
Solution 2:
Snippet will print 155 because the element in the anArray[1] is 55 hence 55 will get addition to 100 and final result will print on to the console i.e 155.
Solution 3:
This wil print each element present in the bArray.
Solution 4:
The statement will print 67. Because the lement present in the anArray[2] is 67.
Solution 5:
the index of the largest of the first num elements of array anArray
Solution 6:
Solution 7:
counts the number of elements of array anArray less than its initial element.
Solution 8:
This will print 89
anArray.Lenght will give out 5 (Length of the array) - 2 will result to 3 so anArray[3] is 89.
Solution 9:
DoSomething (anArray);
Solution 10:
This will print 3026
anArray[2 + 1] * anArray[0] lets simplify this
anArray[3] * anArray[0] //anArray[3] is 89 and anArray[0] is 34
89 * 34 = 3026
Solution 11:
This will rpint out 5. anArray.Length gives the length of the array.
Solution 12:
for(int i = 0; i<bArray.Length; i++){
bArray[i] += 5;
}
bArray[i] += 5; we can write it as bArray[i] = bArray[i] + 5;
we are adding 5 to that element and storing into the same index after adding it.
Solution 13:
Solution 14:
Array.Sort(bArray);
This will sort the array in ascending order.
Solution 15:
Array.IndexOf(bArray, 14);
This will return the index of the element present in the bArray.
Note: I hope I have made the things clear, if you find any issue then please doc omment below, If you liekd the solution then don't forget hit the like button.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.