다음 Java 프로그램의 실행 결과는?
class Super {
int index = 1;
public void printVal() {
System.out.println("super");
}
}
class Sub extends Super {
int index = 2;
public void printVal() {
System.out.println("sub");
}
}
public class Test2 {
public static void main(String args[]) {
Super sup1 = new Sub();
System.out.println(sup1.index);
sup1.printVal();
}
}- ①1super
- ②1sub
- ③2super
- ④2sub
선지를 골라 바로 채점해 보세요.
정답 ②
출처: 인사혁신처 공개 기출(공공데이터포털, 이용허락 제한 없음)