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

题目内容 (请给出正确答案)

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

参考答案

更多 “ 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” 相关考题
考题 She finally allowed the band(乐队)_______. (A)try on(B) try in(C) try out(D) try for

考题 ( 28 )阅读下面程序1 public class Try extends Thread{2 public static void main(String args[ ]){3 Try t = new Try( );4 t.start( );5 }67 public void run( int j){8 int i = 0;9 while(i5){10 System.out.println(" 祝你成功! ");11 i++;12 }13 }14 }该程序要求打印 5 行 “ 祝你成功! ” ,必须改正程序中的某行代码,程序才能完成。选择正确的修改是A )将第 1 行的 extends Thread 改为 implements RunnableB )将第 3 行的 new Try() 改为 new Thread()C )将第 4 行 t.start() 改为 start(t)D )将第 7 行的 public void run( int j) 改为 public void run()

考题 阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。【说明】本程序ExceptionTester实现功能:读入两个整数,第1个数除以第2个数,之后输出。若第2个数为0,则自动进行异常处理。程序如下:(1);public class ExceptionTester{public static void main(String args[]){int result;int number[]=new int[2];boolean valid;for(int i=0;i<2;i++){valid=(2);while(!valid){try{System.out.println("Enter number"+(i+1));number[i]=Integer.valueOf(Keyboard.getString()).intValue();valid=true;}catch(NumberFormatExceptione){System.out.println("Invalid integer entered.Please try again.");}}}by{result=number[0]/number[1];System.out.print(number[0]+"/"+number[1]+"="+result);}catch((3)){System.out.println("Second number is 0,cannot do division!");}}}其中,Keyboard类的声明为:impon java.io.*;public class Keyboard{static BufferedReader inputStream=new (4)(new InputStreamReader(System.in));public static int getInteger(){try{return(Integer,valueOf(inputStream.readLlne().trim()).intValue());}catch(Exceptione){e.printStackTrace();return 0;}}public (5) {by{return(inputStream.readLine());} catch(IOExceptione){return "0";}}}

考题 以下程序执行后的输出结果是( )。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.不确定

考题 本题程序中实现了一个“生产者一消费者问题”。生产者产生一个随机数存入DataPool类中,消费者从中取出数据。DataPool类一次只能存放一个数据。请更正题中带下划线的部分。注意:不改变程序的结构,不得增行或删行。class DataPool{private int data;private boolean isFull;public DataPool(){isFull=false;}public synchronized void putData(int d){if(isFull= =true){try{this.notify();}catch(InterruptedException e){}}data=d;isFull=true;System.out.println("生产了一个数据:"+data);this.notify();}public synchronized int getData(){if(isFull= =false){try{this.wait();}catch(InterruptedException e){}}isFull=false;System.out.println("消费了一个数据"+data);this.wait();return this.data;}boolean getIsFull(){return isFull;}}class Producer extends Thread{DataPool pool;public Producer(DataPool pool){this.pool=pool;}public void run(){for(int i=0; i<10; i++){int data=(int) (Math.random()*1000);try{//用于生产数据sleep(data);}catch(InterruptedException e){}pool.putData(data);}}}class Consumer implements Runnable{DataPool pool;public Consumer(DataPool pool){this.pool=pool;}public void run(){for(int i=0; i<10; i++){int data=pool.getData();try{//用于处理数据sleep((int) (Math.random()*1000));}catch(InterruptedException e){}}}}public class advance}public static void main(String[] args){Data Pool pool=new Data Pool();Producer pro=new Producer(pool);Runnable con=new Consumer(pool);Thread conTh=new Thread(con);&n

考题 阅读下面程序 1 public class Try extends Thread{ 2 public static void main(String args[]){ 3 Try t=new Try(); 4 t.start(); 5 } 6 7 public void run(int j){ 8 int i=0; 9 while(i<5){ 10 System.out.println(“祝你成功!”); 11 i++; 12 } 13 } 14 } 该程序要求打印5行“祝你成功!”,必须改正程序中的某行代码,程序才能完成。选择正确的修改是A.将第1行的extends Thread改为implements RunnableB.将第3行的new Try()改为new Thread()C.将第4行t.start()改为start(t)D.将第7行的public void run(int j)改为public void run()

考题 下面程序的输出结果是 public class Test{ public static void main(String[] args){ int[]array={2,4,6,8,10}; int size=6; int result=-1: try{ for(int i=0;i<sizeresult==-1;i++) if(array[i]==20)result=i; }catch(ArithmeticException e){ System.out.println("Catch---1"); }catch(ArrayIndexOutOfBoundsException e){ System.out.println("Catch---2"); }catch(Exception e){ System.out.println("Catch---3"); } } }A.Catch---1B.Catch一--2C.Catch---3D.以下都不对

考题 设有结构体类型定义: struct try { int one; float two; }*str;若要动态开辟一个结构单元,使指针str指向其首地址,正确的语句是______。A.str=(try*)malloc(sizeof(try));B.*str=(struct try*)malloc(sizeof(struct try));C.str=(strucy try*)malloc(sizeof(struct try));D.str=(struc try)malloc(sizeof(struct try));

考题 阅读以下函数说明和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.不确定

考题 下列程序的输出结果是( )。 Public class Test{ Public static void main(String[]args){ int[]array=(2,4,6,8,10); int size=6; int result=-l: try{ for(int i=0;isizeresult= =-1:) if(array[i]= =20)result=i: } catch(ArithmeticException e){ System.out.println("Catch---1"); } catch(ArraylndexOutOfBoundsException e){ System.out.println("Catch---2"): } catch(Exception e){ System.out.println("Catch---3"): } }A.Catch---1B.Catch---2C.Catch---3D.以上都不对

考题 以下程序执行后的输出结果是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.不确定

考题 She’s going to () that new dress.A、try outB、try onC、try for

考题 对于下列代码段,执行后输出结果是()。 int n,m; int[] a=new int[5]; n=10; m=10; try{ for(inti=0;i=a.Length;i++); a[i]=i; n=1/(n-m); } catch(DivideByZeroExceptione1){ Console.WriteLine(“产生零除异常!”); } catch(IndexOutOfRangeExceptione2) { Console.WriteLine(“产生数组访问越界异常!”); }

考题 研究下面的Java代码:  public class testException{  public static void main(String args[]){       int a[]={0,1,2,3,4};      int sum=0;      try{  for(int i=1;i6;i++)  sum=sum+a[i];  System.out.println("sum="+sum);                 }      catch(ArrayIndexOutOfBoundsException ){                    System.out.println("数组越界");     }  finally{   System.out.println("程序结束");}  } }  输出结果将是()。       A、10  数组越界  程序结束B、10   程序结束C、数组越界  程序结束D、程序结束

考题 public class TestApp{   public static void main(String[] args){   try{   int i = 0;   int j = 1 / i;   System.out.println(“1”);   } catch(Exception e){   System.out.print(“3”);   } finally{   System.out.print(“4”);   }   }   }   上述程序运行后的输出是哪项?() A、 4B、 34C、 43D、 14

考题 public class TestApp{   public int mymethod(){   try{   int i = 0;   int j = 1 / i;   System.out.println(“1”);   }finally{   System.out.print(“4”);  }   return 1;  }  }   上述程序运行后的输出是哪项?() A、 4B、 14C、 41D、 以上都不对

考题 下面关于try、catch和finally语句块的组合使用,正确的是()A、try{,}B、try{,}finally{,}C、try{,}catch{,}finally{,}D、try{,}catch{,}catch{,}

考题 单选题public class TestApp{    public int mymethod(){        try{  int i = 0;           int j = 1 / i;  System.out.println(“1”);         }finally{  System.out.print(“4”);       }  return 1;   } }  上述程序运行后的输出是哪项?()A  4B  14C  41D  以上都不对

考题 单选题现有  class Parser extends Utils {  public static void main (String  []  args)  {  try  {  System.out.print (new Parser () .getlnt ("42"))       }  catch (Exception e) {  System.out.println ("Exc") ;  }      }  int getlnt (String arg)  throws Exception  {     return Integer.parselnt (arg) ;      }      }  class Utils {  int getlnt ()  {  return 42;  }     }  结果是什么?()A  42ExcB  ExcC  42D 编译失败

考题 单选题class Parser extends Utils {  public static void main (String [] args) {  try { System.out.print(new Parser().getInt("42"));  } catch (NumberFormatException n) {  System.out.println("NFExc "); }  }  int getInt(String arg) throws NumberFormatException {  return Integer.parseInt(arg);  }  }  class Utils {  int getInt(String arg) { return 42; }  }  结果为:()A 42B NFExcC 42NFExcD 编译失败

考题 单选题研究下面的Java代码:  public class testException{  public static void main(String args[]){       int a[]={0,1,2,3,4};      int sum=0;      try{  for(int i=1;i6;i++)  sum=sum+a[i];  System.out.println("sum="+sum);                 }      catch(ArrayIndexOutOfBoundsException ){                    System.out.println("数组越界");     }  finally{   System.out.println("程序结束");}  } }  输出结果将是()。A 10  数组越界  程序结束B 10   程序结束C 数组越界  程序结束D 程序结束

考题 单选题You are creating a stored procedure that will delete data from the Contact table in a SQL Server 2005 database. The stored procedure includes the following Transact-SQL statement to handle any errors that occur. BEGIN TRY   BEGIN TRANSACTION   DELETE FROM Person.Contact WHERE ContactID = @ContactID COMMIT TRANSACTION END TRY   BEGIN CATCH   DECLARE @ErrorMessage nvarchar(2000) DECLARE @ErrorSeverity int DECLARE @ErrorState int SELECT @ErrorMessage = ERROR MESSAGE(),@ErrorSeverity=ERROR SEVERITY(),@ErrorState = ERROR STATE() RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState) END CATCH;      You test the stored procedure and discover that it leaves open transactions. You need to modify the stored procedure so that it properly handles the open transactions. What should you do?()A Add a COMMIT TRANSACTION command to the CATCH block.B Remove the COMMIT TRANSACTION command from the TRY block.C Add a ROLLBACK TRANSACTION command to the CATCH block.D Add a ROLLBACK TRANSACTION command to the TRY block.

考题 单选题现有:  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)  { }

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

考题 单选题public class TestApp{  public static void main(String[] args){       try{  int i = 0;           int j = 1 / i;           String myname=null;            if(myname.length()2)              System.out.print(“1”);        }catch(NullPointerException e){  System.out.print(“2”);       }  catch(Exception e){  System.out.print(“3”);       }   } }  上述程序运行后的输出是哪项?()A  3B  2C  231D  32

考题 问答题对于下列代码段,执行后输出结果是()。 int n,m; int[] a=new int[5]; n=10; m=10; try{ for(inti=0;i=a.Length;i++); a[i]=i; n=1/(n-m); } catch(DivideByZeroExceptione1){ Console.WriteLine(“产生零除异常!”); } catch(IndexOutOfRangeExceptione2) { Console.WriteLine(“产生数组访问越界异常!”); }