다음 Java 프로그램의 실행 결과로 옳은 것은?
import java.util.*;
class Test {
public static void main(String args[]) {
LinkedList<Integer> list =
new LinkedList<Integer>();
list.addLast(new Integer(20));
list.addLast(new Integer(10));
Iterator e = list.iterator();
while (e.hasNext()) {
Integer num = (Integer)e.next();
System.out.print(num + " ");
}
while (!list.isEmpty()) {
Integer num = list.removeLast();
System.out.print(num + " ");
}
}
}- ①10 20 10 20
- ②10 20 20 10
- ③20 10 10 20
- ④20 10 20 10
선지를 골라 바로 채점해 보세요.
정답 ③
출처: 인사혁신처 공개 기출(공공데이터포털, 이용허락 제한 없음)