Question: What will be the order of the array elements at the end of the program? int[] array = {14, 8, 16, 11, 13}; for (int

What will be the order of the array elements at the end of the program?

int[] array = {14, 8, 16, 11, 13};

for (int i = 0; i < array.length - 1; i++) {

if (array[i]< array[i + 1]) {

int temp = array[i];

array[i] = array[i + 1];

array[i + 1] = temp;

}

}

14 16 11 13 8

ThrowsArrayIndexOutOfBoundsException

14 8 16 11 13

8 11 13 14 16

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!