assert表示断言。
第1题:
Youaredevelopingaclasslibrarythatwillopenthenetworksocketconnectionstocomputersonthenetwork.Youwilldeploytheclasslibrarytotheglobalassemblycacheandgrantitfulltrust.Youwritethefollowingcodetoensureusageofthesocketconnections.
SocketPermissionpermission=
newSocketPermission(PermissionState.Unrestricted);
permission.Assert();
Someoftheapplicationsthatusetheclasslibrarymightnothavethenecessarypermissionstoopenthenetworksocketconnections.Youneedtocanceltheassertion.
Whichcodesegmentshouldyouuse?()
第2题:
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.
第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正确的说法有()
第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?()
第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?()
第7题:
函数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?()
第9题:
第10题:
Compilation fails.
Compilation succeeds with errors.
Compilation succeeds with warnings.
Compilation succeeds without warnings or errors.
第11题:
line 21
line 23
line 27
line 29
第12题:
Line 13
Line 14
Line 18
Line 20
第13题:
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);
第14题:
不科学的表示功效的断言或保证
A.
B.
C.
D.
E.
第15题:
A.register机制
B.BSR/RP机制
C.Assert机制
D.Join/Prune机制
第16题:
药品广告中,常见的表示功效的断言和保证的用语有哪些,举例说明?
第17题:
测试6的阶乘,断言方法是()?
第18题:
农药的广告内容不得有()。
第19题:
农药广告不得有下列内容()
第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?()
第21题:
All of the assert statements are used appropriately.
Only the assert statement on line 31 is used appropriately.
The assert statements on lines 29 and 31 are used appropriately.
The assert statements on lines 26 and 29 are used appropriately.
The assert statements on lines 29 and 33 are used appropriately.
The assert statements on lines 29, 31, and 33 are used appropriately.
The assert statements on lines 26, 29, and 31 are used appropriately.
第22题:
assert true;
assert false;
assert false : true;
assert false == true;
assert false: false;
第23题:
assert (!(map.contains(x))); map.add(x);
if (x > 0){}else { assert (x==0); }
public void aMethod(int x) { assert (x > 0); }
assert (invariantCondition()); return retval;
switch (x) { case 1: break; case 2: creak; default: assert (x == 0);
第24题: