网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
函数assert的用法是什么?
参考答案
更多 “函数assert的用法是什么?” 相关考题
考题
Whichfragmentisanexampleofinappropriateuseofassertions?()
A.assert(!(map.contains(x)));map.add(x);B.if(x0){}else{assert(x==0);}C.publicvoidaMethod(intx){assert(x0);}D.assert(invariantCondition());returnretval;E.switch(x){case1:break;case2:creak;default:assert(x==0);
考题
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.
考题
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.
考题
测试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))
考题
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.
考题
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 13B、 Line 14C、 Line 18D、 Line 20
考题
单选题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.
考题
单选题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.
考题
单选题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;
考题
单选题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);
考题
单选题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 13B
Line 14C
Line 18D
Line 20
考题
问答题介绍一下Python下range()函数的用法?
热门标签
最新试卷