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
Q17: What does the following code do? Assume
Q18: A method's parameter can be polymorphic, giving
Q19: Java allows one to create polymorphic references
Q20: An class reference can refer to any
Q21: Can a program exhibit polymorphism if it
Q23: Given the following code, class Aggregate is
Q24: Demonstrate how the following array is sorted
Q25: What kind of performance can you expect
Q26: Polymorphism is achieved by
A) overloading
B) overriding
C) embedding
D)
Q27: Explain how to alter the selection sort
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents