What is the scope error in the mystery method?


              public static void main(String[] args)
              {
                  int target = 4;
                  target = mystery(target + 1);
                  System.out.println(sum);
              }
              
              public static int mystery(int target)
              {
                  int sum = 0;
                  for (int i = 0; i < target; target++)
                  {
                      int target = i + 1;
                      sum = sum + target;
                  }
                  return sum;
               }
          
there are two local variables named target that overlap
  • sum is used inside the for loop
  • the loop could repeat infinitely
  • both i and sum are initialized to 0

There are no hints for this question