niusouti.com
更多“assert表示断言。”相关问题
  • 第1题:

    Youaredevelopingaclasslibrarythatwillopenthenetworksocketconnectionstocomputersonthenetwork.Youwilldeploytheclasslibrarytotheglobalassemblycacheandgrantitfulltrust.Youwritethefollowingcodetoensureusageofthesocketconnections.

    SocketPermissionpermission=

    newSocketPermission(PermissionState.Unrestricted);

    permission.Assert();

    Someoftheapplicationsthatusetheclasslibrarymightnothavethenecessarypermissionstoopenthenetworksocketconnections.Youneedtocanceltheassertion.

    Whichcodesegmentshouldyouuse?()


    参考答案:A

  • 第2题:

    Given:11. public void go(int x) {Which statement is true?()

    A.All of the assert statements are used appropriately.

    B.Only the assert statement on line 12 is used appropriately.

    C.Only the assert statement on line 15 is used appropriately.

    D.Only the assert statement on line 18 is used appropriately.

    E.Only the assert statements on lines 12 and 15 are used appropriately.

    F.Only the assert statements on lines 12 and 18 are used appropriately.

    G.Only the assert statements on lines 15 and 18 are used appropriately.


    参考答案:G

  • 第3题:

    什么时候用assert。


    正确答案:

     

    assertion(断言)在软件开发中是一种常用的调试方式,很多开发语言中都支持这种机制。在

    实现中,assertion 就是在程序中的一条语句,它对一个boolean 表达式进行检查,一个正

    确程序必须保证这个boolean 表达式的值为true;如果该值为false,说明程序已经处于不

    正确的状态下,assert 将给出警告或退出。一般来说,assertion 用于保证程序最基本、关

    键的正确性。assertion 检查通常在开发和测试时开启。为了提高性能,在软件发布后,

    assertion 检查通常是关闭的。

    package com.huawei.interview;

    public class AssertTest {

    /**

    * @param args

    */

    public static void main(String[] args) {

    // TODO Auto-generated method stub

    int i = 0;

    for(i=0;i<5;i++)

    {

    System.out.println(i);

    }

    //假设程序不小心多了一句--i;

    --i;

    assert i==5;

    }

    }

  • 第4题:

    关于断言assert正确的说法有()    

    • A、断言是一个包含布尔表达式的语句
    • B、执行断言语句时假定该表达式为 false
    • C、断言可以有两种形式
    • D、当断言表达式为false的时候,系统报告一个Assertionerror

    正确答案:A,C,D

  • 第5题:

    public class Test {  public static void main(String [] args) {  boolean assert = true;  if(assert) {  System.out.println(”assert is true”);  }  }  } Given:  javac -source 1.3 Test.java  What is the result?() 

    • A、 Compilation fails.
    • B、 Compilation succeeds with errors.
    • C、 Compilation succeeds with warnings.
    • D、 Compilation succeeds without warnings or errors.

    正确答案:C

  • 第6题:

    23.int z=5;  24.  25. public void stuff1(int x) {  26. assert (x> 0);  27. switch(x) {  28. case 2: x= 3;  29. default: assert false; } }  30.  31. private void stuff2(int y) { assert (y < 0); }  32.  33. private void stuff3() { assert (stuff4O); } 34.  35. private boolean stuff4() { z = 6; return false; }  Which is true?() 

    • A、 All of the assert statements are used appropriately.
    • B、 Only the assert statement on line 31 is used appropriately.
    • C、 The assert statements on lines 29 and 31 are used appropriately.
    • D、 The assert statements on lines 26 and 29 are used appropriately.
    • E、 The assert statements on lines 29 and 33 are used appropriately.
    • F、 The assert statements on lines 29, 31, and 33 are used appropriately.
    • G、 The assert statements on lines 26, 29, and 31 are used appropriately.

    正确答案:C

  • 第7题:

    函数assert的用法是什么?


    正确答案: 断言assert是仅在debug版本起作用的宏,用于检查“不应该“发生的情况。程序员可以把assert看成一个在任何系统状态下都可以安全使用的无害测试手段。

  • 第8题:

    20. public float getSalary(Employee e) {  21. assert validEmployee(e);  22. float sal = lookupSalary(e);  23. assert (sal>0);  24. return sal;  25. }  26. private int getAge(Employee e) {  27. assert validEmployee(e);  28. int age = lookupAge(e);  29. assert (age>0);  30. return age;  31. }  Which line is a violation of appropriate use of the assertion mechanism?()  

    • A、 line 21
    • B、 line 23
    • C、 line 27
    • D、 line 29

    正确答案:A

  • 第9题:

    问答题
    函数assert的用法是什么?

    正确答案: 断言assert是仅在debug版本起作用的宏,用于检查“不应该“发生的情况。程序员可以把assert看成一个在任何系统状态下都可以安全使用的无害测试手段。
    解析: 暂无解析

  • 第10题:

    单选题
    public class Test {  public static void main(String [] args) {  boolean assert = true;  if(assert) {  System.out.println(”assert is true”);  }  }  } Given:  javac -source 1.3 Test.java  What is the result?()
    A

     Compilation fails.

    B

     Compilation succeeds with errors.

    C

     Compilation succeeds with warnings.

    D

     Compilation succeeds without warnings or errors.


    正确答案: B
    解析: 暂无解析

  • 第11题:

    单选题
    20. public float getSalary(Employee e) {  21. assert validEmployee(e);  22. float sal = lookupSalary(e);  23. assert (sal>0);  24. return sal;  25. }  26. private int getAge(Employee e) {  27. assert validEmployee(e);  28. int age = lookupAge(e);  29. assert (age>0);  30. return age;  31. }  Which line is a violation of appropriate use of the assertion mechanism?()
    A

     line 21

    B

     line 23

    C

     line 27

    D

     line 29


    正确答案: A
    解析: 暂无解析

  • 第12题:

    单选题
    11. public class Test {  12. public void foo() {  13. assert false;  14. assert false;  15. }  16. public void bar(){  17. while(true){  18. assert false;  19. }  20. assert false;  21. }  22. }  What causes compilation to fail?()
    A

     Line 13

    B

     Line 14

    C

     Line 18

    D

     Line 20


    正确答案: C
    解析: 暂无解析

  • 第13题:

    Whichfragmentisanexampleofinappropriateuseofassertions?()

    A.assert(!(map.contains(x)));map.add(x);

    B.if(x>0){}else{assert(x==0);}

    C.publicvoidaMethod(intx){assert(x>0);}

    D.assert(invariantCondition());returnretval;

    E.switch(x){case1:break;case2:creak;default:assert(x==0);


    参考答案:C

  • 第14题:

    不科学的表示功效的断言或保证

    A.

    B.

    C.

    D.

    E.


    正确答案:A

  • 第15题:

    PIM-SM在共享网段断言的机制需要用到的是()

    A.register机制

    B.BSR/RP机制

    C.Assert机制

    D.Join/Prune机制


    参考答案:C

  • 第16题:

    药品广告中,常见的表示功效的断言和保证的用语有哪些,举例说明?


    正确答案:如根治、彻底治愈、安全无毒副作用、疗效最佳、药到病除、无效退款、保险公司保险、最新技术、一吃就灵等。

  • 第17题:

    测试6的阶乘,断言方法是()?

    • A、Assert.assertSame(720,jc.jieChen(6))
    • B、Assert.assertEquals(720,jc.jieChen(6))
    • C、Assert.assertNull(720,jc.jieChen(6))
    • D、Assert.assertTrue(720,jc.jieChen(6))

    正确答案:B

  • 第18题:

    农药的广告内容不得有()。

    • A、使用无毒、无害等表明安全性绝对化断言的内容
    • B、含有不科学的表示功效的断言或者保证的内容
    • C、含有违反农药安全使用规程的文字、语言或者画面的内容
    • D、法律、行政法规规定禁止的其他内容

    正确答案:A,B,C,D

  • 第19题:

    农药广告不得有下列内容()

    • A、使用无毒、无害等表明安全性的绝对化断言的
    • B、含有不科学的表示功效的断言或者保证的
    • C、含有违反农药安全使用规程的文字、语言或者画面的
    • D、法律、行政法规规定禁止的其他内容

    正确答案:A,B,C,D

  • 第20题:

    11. public class Test {  12. public void foo() {  13. assert false;  14. assert false;  15. }  16. public void bar(){  17. while(true){  18. assert false;  19. }  20. assert false;  21. }  22. }  What causes compilation to fail?()  

    • A、 Line 13
    • B、 Line 14
    • C、 Line 18
    • D、 Line 20

    正确答案:D

  • 第21题:

    单选题
    23.int z=5;  24.  25. public void stuff1(int x) {  26. assert (x> 0);  27. switch(x) {  28. case 2: x= 3;  29. default: assert false; } }  30.  31. private void stuff2(int y) { assert (y < 0); }  32.  33. private void stuff3() { assert (stuff4O); } 34.  35. private boolean stuff4() { z = 6; return false; }  Which is true?()
    A

     All of the assert statements are used appropriately.

    B

     Only the assert statement on line 31 is used appropriately.

    C

     The assert statements on lines 29 and 31 are used appropriately.

    D

     The assert statements on lines 26 and 29 are used appropriately.

    E

     The assert statements on lines 29 and 33 are used appropriately.

    F

     The assert statements on lines 29, 31, and 33 are used appropriately.

    G

     The assert statements on lines 26, 29, and 31 are used appropriately.


    正确答案: F
    解析: 暂无解析

  • 第22题:

    单选题
    public class Test{  public static void main( String[] argv ){  // insert statement here  }  }   Which statement, inserted at line 3, produces the following output?()  Exception in thread “main” java.lang.AssertionError: true at Test.main(Test.java:3)
    A

     assert true;

    B

     assert false;

    C

     assert false : true;

    D

     assert false == true;

    E

     assert false: false;


    正确答案: C
    解析: 暂无解析

  • 第23题:

    单选题
    Which fragment is an example of inappropriate use of assertions? ()
    A

     assert (!(map.contains(x))); map.add(x);

    B

     if (x > 0){}else { assert (x==0); }

    C

     public void aMethod(int x) { assert (x > 0); }

    D

     assert (invariantCondition()); return retval;

    E

     switch (x) { case 1: break; case 2: creak; default: assert (x == 0);


    正确答案: B
    解析: 暂无解析

  • 第24题:

    问答题
    药品广告中,常见的表示功效的断言和保证的用语有哪些,举例说明?

    正确答案: 如根治、彻底治愈、安全无毒副作用、疗效最佳、药到病除、无效退款、保险公司保险、最新技术、一吃就灵等。
    解析: 暂无解析