网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
单选题
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);
参考答案
参考解析
解析:
暂无解析
更多 “单选题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);” 相关考题
考题
23.intz=5;24.25.publicvoidstuff1(intx){26.assert(x0);27.switch(x){28.case2:x=3;29.default:assertfalse;}}30.31.privatevoidstuff2(inty){assert(y0);}32.33.privatevoidstuff3(){assert(stuff4O);}34.35.privatebooleanstuff4(){z=6;returnfalse;}Whichistrue?()A.Alloftheassertstatementsareusedappropriately.B.Onlytheassertstatementonline31isusedappropriately.C.Theassertstatementsonlines29and31areusedappropriately.D.Theassertstatementsonlines26and29areusedappropriately.E.Theassertstatementsonlines29and33areusedappropriately.F.Theassertstatementsonlines29,31,and33areusedappropriately.G.Theassertstatementsonlines26,29,and31areusedappropriately.
考题
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);
考题
publicclassTest{publicstaticvoidmain(String[]args){intx=0;assert(x0)?assertionfailed”:assertionpassed”;System.out.println(Finished”);}}Whatistheresult?()
A.finishedB.Compilationfails.C.AnAssertionErroristhrownandfinishedisoutput.D.AnAssertionErroristhrownwiththemessage“assertionfailed”.E.AnAssertionErroristhrownwiththemessage“assertionpassed”.
考题
publicclassTest{publicstaticvoidmain(String[]args){intx=0;assert(x>0):“assertionfailed”;System.out.println(“finished”);}}Whatistheresult?()
A.finishedB.Compilationfails.C.AnAssertionErroristhrown.D.AnAssertionErroristhrownandfinishedisoutput.
考题
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.
考题
下列程序的运行结果是 includeclass Location{private:int X.Y;public:void init(i
下列程序的运行结果是 #include<iostream.h> class Location{ private: int X.Y; public: void init(int=0,int=0); void valueX(int val){X=val;} int valueX( ){ return X;} void valueYA.5 0 6 4B.0 0 6 4C.5 0 6 2D.0 0 6 2
考题
下列程序的输出结果是()。 include int fun(int x) {int a;if(x==0‖x==1) return 3;els
下列程序的输出结果是( )。 #include<stdio.h> int fun(int x) { int a; if(x==0‖x==1) return 3; else a=x-fun(x-2); return a; } void main() { printf("%d",fun(7)); }A.2B.8C.9D.5
考题
下列程序的输出结果是()。includeint fun(int x){ int a;if(x==0||x=1)return 3;elsea=
下列程序的输出结果是( )。#include<stdio.h>int fun(int x){ int a; if(x==0||x=1) return 3; else a=x-fun(x-2); return a;}void main(){ printf("%d",fun(7));}A.2B.8C.9D.5
考题
下列程序的输出结果是( )。 include int fun(int x) {int p;if(x==0‖x==1) return 3;el
下列程序的输出结果是( )。 #include<stdio.h> int fun(int x) { int p; if(x==0‖x==1) return 3; else p=x-fun(x-2); return p; } void main() { print f("\n%d", fun(5)); }A.5B.3C.7D.1
考题
给定java代码如下所示,在A处新增下列()方法,是对cal方法的重载。public class Test { public void cal(int x, int y, int z) { } //A } A、public int cal(int x,int y,float z){return 0;}B、public int cal(int x,int y,int z){return 0;}C、public void cal(int x,int z){}D、public viod cal(int z,int y,int x){}
考题
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 X { public X aMethod() { return this;} } public class Y extends X { } Which two methods can be added to the definition of class Y?()A、 public void aMethod() {}B、 private void aMethod() {}C、 public void aMethod(String s) {}D、 private Y aMethod() { return null; }E、 public X aMethod() { return new Y(); }
考题
20. public float getSalary(Employee e) { 21. assert validEmployee(e); 22. float sal = lookupSalary(e); 23. assert (sal0); 24. return sal; 25. } 26. private int getAge(Employee e) { 27. assert validEmployee(e); 28. int age = lookupAge(e); 29. assert (age0); 30. return age; 31. } Which line is a violation of appropriate use of the assertion mechanism?() A、 line 21B、 line 23C、 line 27D、 line 29
考题
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;
考题
public class Test { public static void main(String[] args) { int x = 0; assert (x 0) ? “assertion failed” : “assertion passed”; System.out.println(“Finished”); } } What is the result?() A、 finishedB、 Compilation fails.C、 An AssertionError is thrown and finished is output.D、 An AssertionError is thrown with the message “assertion failed”.E、 An AssertionError is thrown with the message “assertion passed”.
考题
public class Test { public static void main(String[] args) { int x = 0; assert (x 0): “assertion failed”; System.out.println(“finished”); } } What is the result?() A、 finishedB、 Compilation fails.C、 An AssertionError is thrown.D、 An AssertionError is thrown and finished is output.
考题
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);
考题
1. public class Blip { 2. protected int blipvert(int x) { return 0; } 3. } 4. class Vert extends Blip { 5. // insert code here 6. } Which five methods, inserted independently at line 5, will compile?() A、 public int blipvert(int x) { return 0; }B、 private int blipvert(int x) { return 0; }C、 private int blipvert(long x) { return 0; }D、 protected long blipvert(int x, int y) { return 0; }E、 protected int blipvert(long x) { return 0; }F、 protected long blipvert(long x) { return 0; }G、protected long blipvert(int x) { return 0; }
考题
多选题Given: Which five methods, inserted independently at line 5, will compile?()Aprotected int blipvert(long x) { return 0; }Bprotected long blipvert(int x) { return 0; }Cprivate int blipvert(long x) { return 0; }Dprivate int blipvert(int x) { return 0; }Epublic int blipvert(int x) { return 0; }Fprotected long blipvert(long x) { return 0; }Gprotected long blipvert(int x, int y) { return 0; }
考题
多选题1. public class Blip { 2. protected int blipvert(int x) { return 0; } 3. } 4. class Vert extends Blip { 5. // insert code here 6. } Which five methods, inserted independently at line 5, will compile?()Apublic int blipvert(int x) { return 0; }Bprivate int blipvert(int x) { return 0; }Cprivate int blipvert(long x) { return 0; }Dprotected long blipvert(int x, int y) { return 0; }Eprotected int blipvert(long x) { return 0; }Fprotected long blipvert(long x) { return 0; }Gprotected long blipvert(int x) { return 0; }
考题
多选题public class X { public X aMethod() { return this;} } public class Y extends X { } Which two methods can be added to the definition of class Y?()Apublic void aMethod() {}Bprivate void aMethod() {}Cpublic void aMethod(String s) {}Dprivate Y aMethod() { return null; }Epublic X aMethod() { return new Y(); }
考题
单选题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;
考题
单选题public class Test { public static void main(String[] args) { int x = 0; assert (x 0) ? “assertion failed” : “assertion passed”; System.out.println(“Finished”); } } What is the result?()A
finishedB
Compilation fails.C
An AssertionError is thrown and finished is output.D
An AssertionError is thrown with the message “assertion failed”.E
An AssertionError is thrown with the message “assertion passed”.
考题
多选题给定java代码如下所示,在A处新增下列()方法,是对cal方法的重载。public class Test { public void cal(int x, int y, int z) { } //A }Apublic int cal(int x,int y,float z){return 0;}Bpublic int cal(int x,int y,int z){return 0;}Cpublic void cal(int x,int z){}Dpublic viod cal(int z,int y,int x){}
考题
单选题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.
考题
单选题20. public float getSalary(Employee e) { 21. assert validEmployee(e); 22. float sal = lookupSalary(e); 23. assert (sal0); 24. return sal; 25. } 26. private int getAge(Employee e) { 27. assert validEmployee(e); 28. int age = lookupAge(e); 29. assert (age0); 30. return age; 31. } Which line is a violation of appropriate use of the assertion mechanism?()A
line 21B
line 23C
line 27D
line 29
考题
单选题public class Test { public static void main(String[] args) { int x = 0; assert (x 0): “assertion failed”; System.out.println(“finished”); } } What is the result?()A
finishedB
Compilation fails.C
An AssertionError is thrown.D
An AssertionError is thrown and finished is output.
热门标签
最新试卷