Which statement is true?
哪个语句是正确的?
310 - 035
Leading the way in IT testing and certification tools, www.testking.com
(广告)
-7 -
A. Assertions can be enabled or disabled on a class-by-class basis.
A.在类到类的基础上,声明可以有效或者无效。
B. Conditional compilation is used to allow tested classes to run at full speed.
B.在测试类可以全速运行的情况下,可以使用条件编译。
C. Assertions are appropriate for checking the validity of arguments in a method.
C.使用声明检查方法中参数的正确性是合适的。
D. The programmer can choose to execute a return statement or to throw an exception if
an assertion fails.
D.如果声明失败,程序员可以选择创建一个返回语句或者抛出一个异常。
Answer: A
唉··水平太差了啊··

解决方案 »

  1.   

    ////////////////////////////////////////////
    Given:
    给出:
    1. package test1;
    2. public class Test1 {
    3. static int x = 42;
    4. }
    1. package test2;
    2. public class Test2 extends test1.Test1 {
    3. public static void main(String[] args) {
    4. System.out.println(“x = “ + x);
    5. }
    6. }
    What is the result?
    运行结果是?
    A. x = 0
    B. x = 42
    C. Compilation fails because of an error in line 2 of class Test2.
    C.编译错误,在类Test2的第2行出错。
    D. Compilation fails because of an error in line 3 of class Test1.
    D. 编译错误,在类Test1的第3行出错。
    E. Compilation fails because of an error in line 4 of class Test2.
    E. 编译错误,在类Test2的第4行出错。Answer: C
    //////////////////////////////////////////
    QUESTION NO: 23
    Which statement is true about assertion in the Java programming language?
    在Java中,下面的关于声明的说法哪个是正确的?
    A. Assertion expressions should not contain side effects.
    A.声明语句不能包含歧义(?)。
    B. Assertion expression values can be any primitive type.
    B.声明语句的值可以是任何简单类型。
    C. Assertion should be used for enforcing preconditions on public methods.
    C.声明只能用于公用方法的强制预处理中。
    D. An Assertion Error thrown as a result of a failed assertion should always be handled by
    the enclosing method.
    D.错误的声明总是在封装起来的方法里面处理。
    Answer: A
    ////////////////////////////////////
    QUESTION NO: 43
    Given:
    给出:
    1. class TestA {
    2. TestB b;
    3. TestA() {
    4. b = new TestB(this);
    5. }
    6. }
    7. class TestB {
    8. TestA a;
    9. TestB(TestA a) {
    10. this.a = a;
    11. }
    12. }
    13. class TestAll {
    14. public static void main (String args[]) {
    15. new TestAll().makeThings();
    16. // ...code continues on
    17. }
    18. void makeThings() {
    19. TestA test = new TestA();
    20. }
    21. }
    Which two statements are true after line 15, before main completes? (Choose two)
    对于15行以后和main函数结束之间的部分,哪两句话是正确的。
    A. Line 15 causes a stack overflow.
    A.15行产生一个堆栈溢出。
    B. An exception is thrown at runtime.
    B.将会抛出运行时错误。
    C. The object referenced by a is eligible for garbage collection.
    C.a引用的对象符合垃圾收集的条件。
    D. The object referenced by b is eligible for garbage collection.
    D. b引用的对象符合垃圾收集的条件。
    E. The object referenced by a is not eligible for garbage collection.
    E. a引用的对象不符合垃圾收集的条件。
    F. The object referenced by b is not eligible for garbage collection.
    F. b引用的对象不符合垃圾收集的条件。
    Answer: C, F
      

  2.   

    1. package test1;
    2. public class Test1 {
    3. static int x = 42;
    4. }
    1. package test2;
    2. public class Test2 extends test1.Test1 {
    3. public static void main(String[] args) {
    4. System.out.println(“x = “ + x);
    5. }
    6. }
    What is the result?
    运行结果是?
    A. x = 0
    B. x = 42
    C. Compilation fails because of an error in line 2 of class Test2.
    C.编译错误,在类Test2的第2行出错。
    D. Compilation fails because of an error in line 3 of class Test1.
    D. 编译错误,在类Test1的第3行出错。
    E. Compilation fails because of an error in line 4 of class Test2.
    E. 编译错误,在类Test2的第4行出错。
    Answer: C