問題一覧へ インタフェース 標準

インタフェースの default メソッド

次のコードを実行すると何が表示されますか。

interface Printable {
  default String label() {
    return "I";
  }
}

class Report implements Printable {
  public String label() {
    return "R";
  }
}

public class Main {
  public static void main(String[] args) {
    Printable p = new Report();
    System.out.println(p.label());
  }
}

選択肢