Createa class named ArrayClass .The class will have: · Fields: -an int named siz
ID: 3616541 • Letter: C
Question
Createa class named ArrayClass.The class will have:
· Fields:
-an int named sizeOfArray
-An int named theArray
· No-argConstructor that assigns 0 to sizeOfArray and to each element oftheArray
· ParameterConstructor that accepts an int and an int array
· CopyConstructor that accepts an object of the classArrayApplication
· MethodbubbleSortArray has no argument. the method will sort the theArrayand return the time of sorting process by using methodSystem.nanoTime(); that returns a long number.
· MethodselectionSortArray has no argument. The method will sort thetheArray and return the time of sorting process (as above)
· methodtoString will print out the array elements.
For example: theArray = { 4, 8, 16, 77, 2, 57, 80 }
Output should be:
Array: 4 8 16 77 2 57 80
Explanation / Answer
publicclass ArrayClass { // instancefields privateint sizeOfArray; privateint[] theArray; //constructors publicArrayClass() { sizeOfArray = 0; theArray = new int[0]; } publicArrayClass(int size, int array) { sizeOfArray = size; theArray = array; } publicArrayClass(ArrayApplication app) { } // sorts publiclong bubbleSortArray() { long time =System.nanoTime(); for(int i= 0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.