1. public class Test2 extends MyBase implements MyInterface { int x = 0; 5. public Test2(int inVal) throws Exception { 7. if( inVal != this.x) { 9. throw new Exception("Invalid input"); } } public static void main(String[] args) { 15. Test2 t = new Test2(4); } }
A.the code fails to compile at line1. it's not valid to both implement an interface and extends from a parent class simultaneously.
B.the code fails to compile at line 5.int's not valid for constructors to throw exceptions.
C.the code fails to compile at line9,because this is not valid way to throw an exception.
D.the code fails to compile at line15.the compiler complains that there is an uncaught exception.
E.the code fails to compile at line7,because this is not a valid way to reference variable x.
答案是D,可是我选了A,大家帮帮忙看一下,如果选D帮忙解释一下,谢谢了








,开个玩笑,不过说真的,我一眼看出选D,所以觉得你选A很不可思议。不知道你为什么选A,可以告诉我你的想法吗?这个很重要,这样就能知道你什么知识点没掌握了,因为我觉得没有一本书说这样是不可以的,哈~