QUESTION 86
Given:
What is the result?
A. A, B, C
B. B, C, A
C. Compilation fails
D. The code runs with no output
E. An exception is thrown at runtime
Answer: ( B )
LinkedList有顺序性,
QUESTION 87
Given
What is the result?
A. end
B. Compilation fails
C. exception end
D. exception test end
E. A Throwable is thrown by main
F. An Exception is thrown by main
Answer: ( E )
16行抛出Error, 没有捕获。
Error 和Exception都是Throwable类的子类。Throwable 类是 Java 语言中所有错误或异常的超类。只有当对象是此类(或其子类之一)的实例时,才能通过 Java 虚拟机或者 Java throw 语句抛出。类似地,只有此类或其子类之一才可以是 catch 子句中的参数类型。
QUESTION 88
Given:
Which three, will make code on 37 execute
A. The instance gets garbage collected.
B. The code on line 33 throws an exception.
C. The code on line 35 throws an exception.
D. The code on line 31 throws an exception.
E. The code on line 33 executes successfully.
Answer: ( B, C , E)
QUESTION 89
Given:
What is the result?
A. Compilation fails
B. pi is bigger than 3.
C. An exception occurs at runtime.
D. pi is bigger than 3. Have a nice day.
E. pi is not bigger than 3. Have a nice day.
Answer: ( A )
finally子句只能与try…catch…配合使用,而不能与if...else…配合使用
QUESTION 90
Given:
Which code, inserted at line 16 will cause a java.lang.ClassCastException?
A. Alpha a = x;
B. Foo f = (Delta)x;
C. Foo f = (Alpha)x;
D. Beta b = (Beta)(Alpha)x;
Answer: ( B )
编译时父类型对象和子类型对象相互的强制转换不会发生任何异常。但是,运行时将父类的对象强制转换为子类别的对象时会抛出java.lang.ClassCastException异常。对于本题,运行时(Delta)x会抛出java.lang.ClassCastException异常。