According to the error status, it shows the error is on the
a[j] = term
So if you look at this closely you can see that while loop causes the ArrayIndexOutofBoundsException. So you can write the code like this:
public static int[] Sort(int a[]){
for(int i=1;i<a.length;i++){
int term=a[i];
int j=i-1;
//Sorting
while(j>=0 && term<a[j]){
a[j+1]=a[j];
j--;
}
a[j+1]=term;
}
return a;
}