문제
다음 Java 프로그램의 실행 결과는?
interface Drawable {
① Interface Rectangle ② Custom Rectangle ③ 컴파일 오류 (인터페이스 메서드 재정의 불가) ④ Interface Custom
정답
2번
해설
인터페이스의 default 메서드는 구현 클래스에서 재정의할 수 있다. Rectangle 클래스에서 display()를 재정의했으므로 "Custom "이 출력되고, draw() 메서드 구현에 의해 "Rectangle "이 출력된다.