MCQs > IT & Programming > Java > What exception is thrown by this code, if arr[j]>arr[j+1]: public static void main(String[] args) { int []arr={12,23,43,34,3,6,7,1,9,6}; { int temp; for (inti=0;iarr[j+1]) { temp=arr[j]; arr[j+1]=arr[j]; arr[j+1]=temp; } } } } for(inti=0; i

Java MCQs

What exception is thrown by this code, if arr[j]>arr[j+1]:

public static  void main(String[] args) {

int []arr={12,23,43,34,3,6,7,1,9,6};

        { 

int temp;

for (inti=0;i<arr.length;i++)

              { 

for (int j=0;j<arr.length-i;j++ )

                {

if (arr[j]>arr[j+1])

                 { 

temp=arr[j];

arr[j+1]=arr[j];

arr[j+1]=temp;

                  }

                }

              }

            }

for(inti=0; i<arr.length; i++)

         {

System.out.print(arr[i] + " ");

         }

    }

Answer

Correct Answer: ArrayIndexOutOfBoundException

Explanation:

Note: This Question is unanswered, help us to find answer for this one

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it