← 목록

정보처리기사 실기 2025년 2회

Q.182025년2회10과목 · Java배점 5점
아래 코드의 출력값을 작성하시오.
static interface F {
    int apply(int x) throws Exception;
}
public static int run(F f) {
    try {
        return f.apply(3);
    } catch (Exception e) {
        return 7;
    }
}
public static void main(String[] args) {
    F f = (x) -> {
        if (x > 2) throw new Exception();
        return x * 2;
    };
    System.out.print(
        run(f) + run((int n) -> n + 9));
}
댓글…

나만의 풀이, 암기법을 나눠 보세요. 정답이 포함될 수 있어요.

해설
왼쪽에서 보기를 고르고 정답 확인을 누르면
여기에 정답과 해설이 표시됩니다.