다음 Java 코드의 출력은?
class Main {
static class Box {
int value = 4;
int add(int x) { value += x; return value; }
}
public static void main(String[] args) {
Box b = new Box();
int r = b.add(3);
System.out.print(r + b.value);
}
}정답 4번
add 호출 뒤 r과 b.value는 모두 7이므로 합은 14이다.
콘텐츠 정보
- 자료 유형
- 편집복원
- 검수 상태
- 내용 검수 완료
- 해설 작성·검수
- 정처LAB 편집 기준
- 최종 검수
- 2026-08-21