Compile time Error

exercise No. 273

Q:

We consider:

String getResult(int a, int b) {

  if (0 == a % 2) {
    return "o.K.";
  } else if (a + b < 0) {
    return "Quite o.K.";
  } else if (4 < a * b) {
    return "bad";
  }
}

Why does the compiler complains about a Missing return statement despite several being present?

A:

The if-clause is incomplete: A final else is missing:

String getResult(int a, int b) {

  if (0 == a % 2) {
    return "o.K.";
  } else if (a + b < 0) {
    return "Quite o.K.";
  } else if (4 < a * b) {
    return "bad";
  }else {
    return "Schlecht";
  }
}