다음은 Java로 작성된 프로그램이다. 이에 대한 설명으로 가장 부적절한 것은?
class People {
public void hello() {
System.out.println("Hello !"); }
public void introduce() {
System.out.println("Hi !"); }
}
class Student extends People {
public void introduce() { hello(); }
}
class Main {
public static void main(String args) {
People p = new People();
Student s = new Student();
call(p);
call(s);
}
static void call(People p) { p.introduce(); }
} |
<실행결과>
Hi !
Hello ! |
- ①call 메소드의 정의와 사용에서 다형성(polymorphism) 기법이 사용되었다.
- ②call 메소드의 정의와 사용에서 동적 바인딩(dynamic binding) 기법이 사용되었다.
- ③Student 클래스의 정의에서 상속(inheritance) 기법이 사용되었다.
- ④Student 클래스의 정의에서 중복정의(overloading) 기법이 사용되었다.
선지를 골라 바로 채점해 보세요.
정답 ④
출처: 인사혁신처 공개 기출(공공데이터포털, 이용허락 제한 없음)