1. package foo;
2.
3. import java.util.Vector;
4.
5. private class MyVector extends Vector {
6. int i = 1;
7. public MyVector() {
8. i = 2;
9. }
10. }
11.
12. public class MyNewVector extends MyVector {
13. public MyNewVector() {
14. i = 4;
15. }
16. public static void main(String args[]) {
17. MyVector v = new MyNewVector();
18. }
19. }
What is the result?
A. Compilation succeeds.
B. Compilation fails because of an error at line 5.
C. Compilation fails because of an error at line 6.
D. Compilation fails because of an error at line 14.
E. Compilation fails because of an error at line 17.
비 : 생성자는 클래스의 접근제한자와 일치해야함.
1. class TestSuper {
2. TestSuper(int i) { }
3. }
4. class TestSub extends TestSuper{ }
5. class TestAll {
6. public static void main (String [] args) {
7. new TestSub();
8. }
9. }
Which is true?
A. Compilation fails.
B. The code runs without exception.
C. An exception is thrown at line 7.
D. An exception is thrown at line 2.
컴파일 에러. 생성자가 없을 때는 부모의 디폴트 생성자를 호출하는데 인자가 있는 생성자 만 있기에.
10. int i = 0;
11. for (; i <4; i += 2) {
12. System.out.print(i + "");
13. }
14. System.out.println(i);
What is the result?
A. 0 2 4
B. 0 2 4 5
C. 0 1 2 3 4
D. Compilation fails.
E. An exception is thrown at runtime.
0, 2 찍고 후처리로 4 되었을 때 이탈하게 된다.
그리고 4를 찍고 종료.
2011년 2월 24일 목요일
피드 구독하기:
댓글 (Atom)
UPBIT is a South Korean company, and people died of suicide cause of coin investment.
UPBIT is a South Korean company, and people died of suicide cause of coin. The company helps the people who control the market price manipu...
-
□ native modifier 는 자바가 아닌 다른 언어로 작성된 코드를 자바에서 사용하기 위한 것 □ transient modifier 는 객체가 직렬 화되는 과정에서 해당 필드가 저장되지 않아야 한다는 것을 알리기 위해 사용 ...
-
연휴 마지막날 아침... 산책을 하다 한장 찍어보았다. 인생도 마찬가지로 길의 끝을 모른체 선택을 해야하는 경우가 발생한다. 나중에 그 기준이 바뀔수도 있지만. 지금 기준은 많은 사람이 함께 갈 수 있는 길을 선택하고 싶다.
-
#오픈그록을 외부페이지로 설정하기 위해 먼저 톰캣을 설치하여 보자 1. 톰캣? - 아파치 소프트웨어 재단에서 개발된 서블릿 컨테이너만 있는 웹 애플리케이션 서버. 톰캣은 웹서버와 연동하여 실행할 수 있는 자바환경을 제공하여 자바 서버 페...
댓글 없음:
댓글 쓰기
국정원의 댓글 공작을 지탄합니다.