网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
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.


参考答案

参考解析
解析: 暂无解析
更多 “单选题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.” 相关考题
考题 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);

考题 下列程序的运行结果是 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

考题 下列程序的运行结果是inClUdeclass Location{private:int X,Y;pubhc:void init(int 下列程序的运行结果是 #inClUde<iostream.h> class Location{ private: int X,Y; pubhc: void init(int=0,int=0) ; void valueX(int val) {X=val;} int valueX( ) {retum X;} void valueY(int val) {Y=val;} int valueY( ) {retum Y;}};void Location: :init(int initX,int initY) { X=initX; Y=initY;} Void main( ) { Location A,B; A. init( ) ; A. valueX(5) ; cout < < A. valueX( ) < < endl < < A. valueY( ) < < endl; B. init(6,2) ; B. valueY(4) ; cout < < B. valueX( ) < < endl < < B. valueY( ) < < endl;}A.5B.0C.5D.0 0 0 0 0 6 6 6 6 4 4 2 2

考题 下面程序的执行结果为 ‘ #include"iostream" using namespace std; class A { int a; public: void Sera(int x){a=x;} void Display_a(){cout<<a<<endl;} }; class B { int b; public: void Setb(int x){ b=x;} void Dispaly_b() {cout<<b<<endl;} }; class C:public A,private B { private: int c; public: void Setc(int x,int y,int z) { c=z;Sera(x);Serb(y);} void Display_c(){cout<<c<<endl;} }; ① void main() ② { ③ C cc; ④ cc.Seta(1); ⑤ cc.Display_a(); ⑥ cc.Setc(2,2,3); ⑦ cc.Dispaly_b(); ⑧ cc.Display_c(); }A.输出为2 2 3B.有错误在第5行C.输出为1 2 3D.有错误在第7行

考题 下列程序的运行结果是 includeclassLocation{ private: int X,Y; public: void init 下列程序的运行结果是 #include<iostram.h> classLocation{ private: int X,Y; public: void init(int=0, int=0) ; void valueX(int val){X=val:} int valueX(){return X;} void valueY(int val){Y=val;} int valueY(){returnY;}}; void Location∷init(int initX,int initY) { X=initX; Y=initY;} void main() { LocationA,B; A.init(); A.ValueX(5); cout <<A.ValUeX() <<endl<<A,valueY() <<endl; B.init(6,2); B.valueY(4) ; cout<<B.valueX() <<endl<<B.valueY() <<endl;}A.5 0 6 4B.0 0 6 4C.5 0 6 2D.0 0 6 2

考题 下列程序执行之后,将输出 public class exl9 { public static void main(string[] args) { int x=3; int y=7; switch(y/x){ case 1: y*=2; break; case 2: y*=3; break; case 3: y*=4; break; default: y=0; } System.out.print(y); } }A.28B.21C.14D.0

考题 若有以下程序:includeusing namespace std;class A{private:int a; public:void seta 若有以下程序: #include<iostream> using namespace std; class A { private: int a; public: void seta(int x) { a=x; } void showa() { cout<<a<<","; } }; class B { private: int b; public: void setb(int x) { b=x; } void showb() { cout<<b<<",”; } }; class C:pUblic A,private B { private: int c; public: void setc(int x,int y,int z) { c=z; seta(x); setb(y); } void showc() { showa(); showb(); cout<<c<<end1; } }; int main() { Cc; c.setc(1,2,3); c.showc(); retrun 0; } 程序执行后的输出结果是A.1,2,3B.1,1,1C.2,2,2D.3,3,3

考题 若有以下程序:includeusing namespace std;class A{private:inta;public:voidseta(in 若有以下程序: #include <iostream> using namespace std; class A { private: int a; public: void seta(int x) { a=x; } void showa() { cout<<a<<","; } }; class B { private: int b; public: void setb (int x) { b=x; } void showb() { cout<<b<<","; } }; class C :public A,private B { private: int c; public: void setc(int x, inc y, int z) { c=z; seta (x); setb (y); } void showc() { showa (); showb (); cout<<c<<end1; } }; int main () { C c; c. setc(1,2,3); c.showc(); return 0; } 程序执行后的输出结果是A.1,2,3B.1,1,1C.2,2,2D.3,3,3

考题 若有以下程序:include using namespace std;class A{private:int a;public:void seta 若有以下程序:#include <iostream>using namespace std;class A{private: int a;public: void seta(int x) { a=x; } void showa() { cout<<a<<","; }};class B{private: int b;public: void setb(int x) { b=x; } void showb() { cout<<b<<","; }};class C: public A, private B{private: int c;public: void setc(int x, int y, int z) { c=z; seta(x); setb(y); } void showc() { showa(); showb(); cout<<c<<end1; }};int main(){ C c; c.setc(1,2,3); c.showc(); return 0;}程序执行后的输出结果是( )。A.1,2,3B.1,1,1C.2,2,2D.3,3,3

考题 下列程序的运行结果是( )。 #includeiostream.h class Loeation{ private: int X,Y; public: void init(int=0,int=0); void valueX(int val){X=val;} int valueX{returnx;} void valueY(int val){Y=val;} int valueY{return Y;}}; void Location::init(int initX,int initY) {X=initX; Y=initY4} void main(X {Location A,B; A.init; B.value X(5); coutA.value XendlA.value Yendl; B.init(6,2); B.value Y(4); eoutB.value XendlB.value Yendl; }A.5 0 6 4B.0 0 6 4C.5 0 6 2D.0 0 6 2

考题 includeiostream.hclass A{private:int x,y;public:void f1(int i=0,int j=0){x=i;y=j;}void print(){coutx yendl;}void f1(int i=0){x=i,y=0;}};void main(){A a;a.f1(5);a.print();}

考题 给定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.

考题 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 ConstOver {  public ConstOver (int x, int y, int z)  {  }  }   Which two overload the ConstOver constructor?()   A、 ConstOver ( ) { }B、 Protected int ConstOver ( ) { }C、 Private ConstOver (int z, int y, byte x) { }D、 Public Object ConstOver (int x, int y, int z) { }E、 Public void ConstOver (byte x, byte y, byte z) { }

考题 public class MethodOver {   private int x, y;   private float z;   public void setVar(int a, int b, float c){   x = a;   y = b;   z = c;   }   }   Which two overload the setVar method?()A、 void setVar (int a, int b, float c){  x = a;  y = b;  z = c;  }B、 public void setVar(int a, float c, int b) {  setVar(a, b, c);  }C、 public void setVar(int a, float c, int b) {  this(a, b, c);  }D、 public void setVar(int a, float b){  x = a;  z = b;  }E、 public void setVar(int ax, int by, float cz) {  x = ax;  y = by;  z = cz;  }

考题 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.

考题 10. class Inner {  11. private int x;  12. public void setX( int x) { this.x = x; }  13. public int getX() { return x; }  14. }  15.  16. class Outer {  17. private Inner y;  18. public void setY( Inner y) { this.y = y; }  19. public Inner getY() { return y; }  20. }  21.  22. public class Gamma {  23. public static void main( String[] args) { 24. Outer o = new Outer(); 25. Inner i = new Inner();  26.int n=10;  27. i.setX(n);  28. o.setY(i);  29. // insert code here  30. System.out.println( o.getY().getX());  31. }  32. }  Which three code fragments, added individually at line 29, produce the output 100?()A、 n = 100;B、 i.setX( 100);C、 o.getY().setX( 100);D、 i = new Inner(); i.setX( 100);E、 o.setY( i); i = new Inner(); i.setX( 100);F、 i = new Inner(); i.setX( 100); o.setY( i);

考题 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);

考题 public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()A、 public class Circle implements Shape { private int radius; }B、 public abstract class Circle extends Shape { private int radius; }C、 public class Circle extends Shape { private int radius; public void draw(); }D、 public abstract class Circle implements Shape { private int radius; public void draw(); }E、 public class Circle extends Shape { private int radius;public void draw() {/* code here */} }F、 public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }

考题 Which two code fragments are most likely to cause a StackOverflowError?()A、int []x = {1,2,3,4,5};for(int y = 0; y  6; y++)    System.out.println(x[y]);B、static int[] x = {7,6,5,4};static { x[1] = 8;x[4] = 3; }C、for(int y = 10; y  10; y++)doStuff(y);D、void doOne(int x) { doTwo(x); }void doTwo(int y) { doThree(y); }void doThree(int z) { doTwo(z); }E、for(int x = 0; x  1000000000; x++) doStuff(x);F、void counter(int i) { counter(++i); }

考题 单选题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);

考题 多选题public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()Apublic class Circle implements Shape { private int radius; }Bpublic abstract class Circle extends Shape { private int radius; }Cpublic class Circle extends Shape { private int radius; public void draw(); }Dpublic abstract class Circle implements Shape { private int radius; public void draw(); }Epublic class Circle extends Shape { private int radius;public void draw() {/* code here */} }Fpublic abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }

考题 多选题public class MethodOver {  private int x, y;  private float z;  public void setVar(int a, int b, float c){  x = a;  y = b;  z = c;  }  }   Which two overload the setVar method?()Avoid setVar (int a, int b, float c){ x = a; y = b; z = c; }Bpublic void setVar(int a, float c, int b) { setVar(a, b, c); }Cpublic void setVar(int a, float c, int b) { this(a, b, c); }Dpublic void setVar(int a, float b){ x = a; z = b; }Epublic void setVar(int ax, int by, float cz) { x = ax; y = by; z = cz; }

考题 单选题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.