[7급 국가직 프로그래밍언어론 2011년 8번]

다음 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 + " ");
      }
   }
}
프로그래밍언어론
  1. ①10 20 10 20
  2. ②10 20 20 10
  3. ③20 10 10 20
  4. ④20 10 20 10

선지를 골라 바로 채점해 보세요.

정답 ③

출처: 인사혁신처 공개 기출(공공데이터포털, 이용허락 제한 없음)

신고가 접수됐습니다. 감사합니다.

오류 신고