interface TestA {
String toString();
}
public class Test {
public static void main(String[] args) {
System.out.println(new TestA() {
public String toString() {
return "test";
}
});
}
}
结果是什么?
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.
这个问题的答案是什么?为什么?关于这个问题,我还有一个疑问。在第4行中,我们正在创建一个A的对象。有可能创建一个接口的对象吗?