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

题目内容 (请给出正确答案)
单选题
try {  int x = 0;  int y = 5 / x;  } catch (Exception e) {  System.out.println(“Exception”);  } catch (ArithmeticException ae) {  System.out.println(“Arithmetic Exception”);  }  System.out.println(“finished”);  What is the result?()
A

 finished

B

 Exception

C

 Compilation fails.

D

 Arithmetic Exception


参考答案

参考解析
解析: The correct answer to this question is D. When an int value is divided by zero, a runtime exception occurs. There are no compilation errors. 
更多 “单选题try {  int x = 0;  int y = 5 / x;  } catch (Exception e) {  System.out.println(“Exception”);  } catch (ArithmeticException ae) {  System.out.println(“Arithmetic Exception”);  }  System.out.println(“finished”);  What is the result?()A  finishedB  ExceptionC  Compilation fails.D  Arithmetic Exception” 相关考题
考题 阅读下面程序: include void fun(int n) { int x(5); static int y(10); if(n>0) { 阅读下面程序:include<iostream.h>void fun(int n){int x(5);static int y(10);if(n>0){++x;++y;cout<<x<<","<<y<<end1;}}void main(){int m(1);fun(m);}则该程序的输出结果是______。

考题 阅读下面程序: include void f(int n) { int x(5); static int y(10); if(n>0) { ++ 阅读下面程序:include<iostream.h>void f(int n){int x(5);static int y(10);if(n>0){++x;++y;cout<<x<<","<<y<<endl;}}void main(){int m(1);f(m),}则该程序的输出结果是【 】

考题 下列函数原型声明中错误的是A.void Fun(int x=O,int y=0);B.void Fun(int x,int y);C.void Fun(int x,int y=0);D.void Fun(int x=0,int y);

考题 执行以下程序段后,变量x=______,y______。int x=5;int y=0;y = --x * 3;

考题 给定C语言程序:int foo(int x, int y,int d){if ( x !=0 ) {if ( y == 0 ) d = d / x;else d=d/(x*y);} else {if ( y == 0 ) d = 0;else d=d/y;}return d;}当用路径覆盖法进行测试时,至少需要设计(31)个测试用例。A.3B.4C.5D.8

考题 下列代码的执行结果是______。public class Test{public static void main(String[]args){int[]x={0, 1, 2, 3};for(int i=0;i<3;i+=2){try{System.out println(x[i+23/x[i]+x[i+1]);}catch(ArithmeticException e){System.out.println("error1");}catch (Exception e){System.out.println("error2");}}}}A) error1B) error2C) error1D) 2error2 error2A.B.C.D.

考题 有如下程序:include void fun (int x,int y){int t=x;x=y;y=t;}int main(){ int 有如下程序: #include <iostream> void fun (int x,int y){int t=x;x=y;y=t;} int main() { int a[2]={23,42}; fun (a[1],a[0]; std::cout<<a[0]<<”,”<<a[1]<<std:: ond1; retum0; }执行后的输出结果是______ 。A.41,41B.23,23C.13,42D.42,23

考题 以下程序执行后的输出结果是( )。include usingnamespacestd;void try(int,int,int,in 以下程序执行后的输出结果是( )。 #include <iostream> using namespace std; void try(int,int,int,int); int main ( ) { int x,y,z,r; x=1; y=2; try(x,y,z,r); cout<<r<<end1; return 0; } void try(int x,int y, int z,int r) { z = x+y; x = X*X; y = y*y; r = z+x+y; }A.18B.9C.10D.不确定

考题 下面程序的运行结果为_____。 include void fun(int x=0,int y=0) { cout 下面程序的运行结果为_____。include<iostream.h>void fun(int x=0,int y=0){cout < < x < < y;}void main( ){fun(5) ;}

考题 有如下程序:include void fun(int x, int y){int t=x;x=y;y=t;}int main (){int 有如下程序: #include <iostream> void fun(int x, int y){int t=x;x=y;y=t;} int main () { int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; } 执行后的输出结果是A.42,42B.23,23C.23,42D.42,23

考题 for(int x=0,y=0;!x=5;y++)语句执行循环的次数是( )。A.0B.5C.6SXB for(int x=0,y=0;!x&&y=5;y++)语句执行循环的次数是( )。A.0B.5C.6D.无穷

考题 下列代码的执行结果是( )。 public class Test{ public static void main(String[]args){ int[]x={0,1,2,3}; for{int i=0;i3;1+=2){ try{ systcm.OUt.println(x[i+2]/x[i]+x[i+1]); }catch(ArithmeticException e){ System.OUt.println("errorl"): }catch(Exception e){ System.OUt.println("error2"): } } } }A.errorlB.error2C.errorl orror2D.2 error2

考题 下列函数原型声明中错误的是______。A.void Fun (int x=O,int y=O);B.void Fun(int x,int y);C.void Fun(int x,int y=0);D.void Fun(int x=0,int y);

考题 阅读以下函数说明和C语言函数,将应填入(n)处的字句写在对应栏内。【函数2.1】void sort(char *s,int num){int i,j--num;char t;while(j-->1)for(i=0;i<j;i++)if(s[i]>s[i+1]){t=s[i];s[i]=s[i+1];s[i+1]=t;}void main(){char *s="CEAedea";sort(s,5);printf("%s",s);}上述程序的结果是(1)【函数2.2】void main(){ union {int ig[6];Char s[12];} try;try. ig[0]=0x4542; try.ig[1]=0x2049;try. ig[2]=0x494a; try.ig[3]=0x474e;try. ig[4]=0x0a21; try.ig[5]=0x0000;pintf("%s",try, s);}上述程序的结果是(2)【函数2.3】void main(){ char *letter[5]= { "ab","efgh","ijk","nmop","st"};char **p;int i;p=letter;for(i=0;i<4;i++) .printf("%s",p[i]);}上述程序的结果是(3)【函数2.4】main(){int i=4,j=6,k=8,*p=I,*q=j,*r=k;int x,y,z;x=p==i;y=3*-*p/(*q)+7;z=*(r=k)=*p**q;printf("x=%d,y=%d,z=%d",x,y,z);}上述程序的结果是(4)【函数2.5】int a[]={5,4,3,2,1 };void main(){int i;int f=a[0];int x=2;for(i=0;i<5;i++)f+=f*x+a[i];printf("%d",f);}上述程序的结果是(5)

考题 以下程序执行后的输出结果是include using namespace std;void try(int,int,int,int) 以下程序执行后的输出结果是 #include <iostream> using namespace std; void try(int,int,int,int); int main () { int x,y,z,r; x =1 ; y = 2; try(x,y,z,r); cout<<r<<endl; return 0; } void try(int x,int y,int z,int r) { z = x+y; x = x*x; y = y*y; r = z+x+y; }A.18B.9C.10D.不确定

考题 下列函数原型声明中错误的是( )。A.void fuc(int x=0,int y=0)B.void fnc(int x,int y)C.void fuc(int x,int y=0)D.void fuc(int x=0,int y)

考题 在下面程序运行后,输出结果为 ______。includevoid count(int x[],int n,int y 在下面程序运行后,输出结果为 ______。 #include<iostream.h> void count(int x[],int n,int y){ int k; y=0; for(k=0:k<n;k++) if(x[k]<0) y++; } void main(){ int b[]={2,1,-8,-3,7,2,4,6,0,-13}; int x; count(b,10,x); cout<<“x”<<x<<end1; }A.x=3B.x=5C.出错D.x=0

考题 以下( )表达式是不合法的。A.String x="Sky";int y=5;x + =y:B.String x="Sky":int y=5:if(x==y){}C.String x="Sky":int y=5:x=x+y:D.String x=null:int y=(x!=null) (x.length( )>0)?x.length:0

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

考题 以下程序执行后的输出结果是include.using namespace std;void try(int,int,int,int) 以下程序执行后的输出结果是 #include<iostream>. using namespace std; void try(int,int,int,int); int main() { int x,y,z,r; x=1; y=2; try(x,y,z,r); cout<<r<<end1; return 0; } void try(int x,int y, int z,int r) { z = x+y; x = x*x; y = y*y; r = z+x+y; }A.18B.9C.10D.不确定

考题 try {  int x = 0;  int y = 5 / x;  } catch (Exception e) {  System.out.println(“Exception”);  } catch (ArithmeticException ae) {  System.out.println(“Arithmetic Exception”);  }  System.out.println(“finished”);  What is the result?()  A、 finishedB、 ExceptionC、 Compilation fails.D、 Arithmetic Exception

考题 5. class Order2 implements Runnable {  6. public void run() {  7. for(int x = 0; x 〈 4; x++) {  8. try { Thread.sleep(100); } catch (Exception e) { }  9. System.out.print("r");  10. } }  11. public static void main(String [] args) {  12. Thread t = new Thread(new Order2());  13. t.start();  14. for(int x = 0; x 〈 4; x++) {  15. // insert code here  16. System.out.print("m");  17. } } }  哪一个插入到第15行,最有可能产生输出 rmrmrmrm ?()  A、Thread.sleep(1);B、Thread.sleep(100);C、Thread.sleep(1000);D、try { Thread.sleep(100); } catch (Exception e) { }

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

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

考题 多选题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; }

考题 单选题现有:  5.  class Order2 implements Runnable  {     6.    public void run()  {     7. for (int x- o;  x4;  x++)  {  8. try{Thread.sleep(100);  )catch  (Exception e)  {  }     9.    System.out.print("r");     10.    }  }  11.    public static void main(string  []  args)  {     12.    Thread t=new Thread(new order2());     13.    t.start();  14.    for(int x=0;  x4;  x++)  {     15.    //insert code here     16.    System.out.print("m");     17.  }  }  }  哪一个插入到第15行,最有可能产生输出 rmrmrmrm?()A   Thread.sleep(1);B   Thread.sleep(100);C   Thread.sleep(1000);D   try{  Thread.sleep(1);  )  catch  (Exception e)  {  }E   try{Thread.sleep(100);  )  catch  (Exception  e)  {  }F   try{Thread.sleep(1000);  ) catch  (Exception  e)  { }

考题 多选题Which two code fragments are most likely to cause a StackOverflowError?()Aint []x = {1,2,3,4,5};for(int y = 0; y  6; y++)    System.out.println(x[y]);Bstatic int[] x = {7,6,5,4};static { x[1] = 8;x[4] = 3; }Cfor(int y = 10; y  10; y++)doStuff(y);Dvoid doOne(int x) { doTwo(x); }void doTwo(int y) { doThree(y); }void doThree(int z) { doTwo(z); }Efor(int x = 0; x  1000000000; x++) doStuff(x);Fvoid counter(int i) { counter(++i); }