My Java Quiz

The ultimate place to learn Java!

Question #33: Which of the statements is true about the following code?

public class A {

  int f1 (boolean flag) {
    int result;
    if (flag) {
      result = 1;
    } else {
      result = 2;
    }
    return result;
  }

  int f2 (boolean flag) {
    int result;
    if (flag) result = 1;
    if (!flag) result = 2;
    return result;
  }

}