Multiple Choice
Which of the following methods will sort an array of floats in ascending order?
A) void arrange(float[] ary)
{
For (int n = 0; n < ary.length; n++)
For (int k = n; k < ary.length; k++)
If (ary[n] > ary[k])
{
Float x = ary[n];
Ary[n] = ary[k];
Ary[k] = x;
}
}
B) void arrange(float[] ary)
{
For (int n = 0; n < ary.length; n++)
For (int k = n; k < ary.length; k++)
If (ary[n] < ary[k])
{
Float x = ary[n];
Ary[n] = ary[k];
Ary[k] = x;
}
}
C) void arrange(float[] ary)
{
For (int n = 1; n <= ary.length; n++)
For (int k = n; k < ary.length; k++)
If (ary[n] > ary[k])
{
Float x = ary[n];
Ary[n] = ary[k];
Ary[k] = x;
}
}
D) void arrange(float[] ary)
{
For (int n = 0; n < ary.length; n++)
For (int k = n; k < ary.length; k++)
If (ary[n] > ary[k])
Float x = ary[n];
Ary[n] = ary[k];
Ary[k] = x;
}
E) None of these
Correct Answer:

Verified
Correct Answer:
Verified
Q30: Although insertion sort and selection sort have
Q31: An interface reference can refer to any
Q32: Code Example Ch 10-1<br>An int array
Q33: Given the following code, class Aggregate is
Q34: A method's parameter can be polymorphic, giving
Q35: What does the following code do? Assume
Q36: It is possible to sort an array
Q37: In order to determine the type that
Q38: To swap the 3rd and 4th elements
Q40: Code Example Ch 10-1<br>An int array