two test cases when end is initialized to 1001 instead of 1000.pleeeease helpp

static int binaryforx(int x){

 int start=0;
  int end=1001;


  while(start<=end){

  int mid=(start+end)/2;

print("?"+" "+x+" "+mid);
     String response=sc.next();
     if(response.equals("YES")==true){
      start=mid+1;
     }
     else end=mid-1;

  }
    
    return start;

}