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] + " ");
}
}
Correct Answer: ArrayIndexOutOfBoundException
Explanation:
Note: This Question is unanswered, help us to find answer for this one
More Java MCQ Questions