Question 20 : 내부 무명 클래스

Given:
1. interface TestA { String toString(); }
2. public class Test {
3.     public static void main(String[] args) {
4.         System.out.println(new TestA() {
5.             public String toString() { return “test”; }
6.         });
7.     }
8. }

What is the result?

A. test
B. null
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 1.
E. Compilation fails because of an error in line 4.
F. Compilation fails because of an error in line 5.


Answer : A
반응형

'잘난놈되기 > SCJP' 카테고리의 다른 글

Q021. 추상클래스  (1) 2008.05.03
Q019. 클래스의 형변환  (0) 2008.04.13
Q018. 인터페이스  (0) 2008.04.13
Q017. import static  (0) 2008.04.11
Q016. 내부클래스  (0) 2008.04.04

+ Recent posts