end
Compilation fails.
exception end
exception test end
A Throwable is thrown by main.
An Exception is thrown by main.
第1题:
给出下列的不完整的方法,则下列的哪个声明可以被加入①行完成此方法的声明? ① ② { success = connect( ); ③ if (success = = - 1 ) { ④ throw new TimedoutException( ) ⑤ } ⑥ }
A.public void method( )
B.public void method( ) throws Exception
C.public void method( ) throw TimedoutException
D.public throw TimedOutException void method( )
第2题:
下列程序的运行结果是( )。 public class test{ private String[]data={¨10","10.5"); public void fun{ double s=0: for(int i=0;i<3;j++){ try{ s=s+Integer.parseInt(data[i]); catch(Exception e){ System.out.print("errorl:"+data[i]); } } } public static void main(string[]args){ try{ test d=new test: fun: }catch(Exception e){ System.OUt.println("error2") } } }
A.errorl:10.5
B.error2
C.errorl:10.5 error2
D.以上都不对
第3题:
给出下列的不完整的方法,则下列的( )声明可以被加入①行完成此方法的声明。 ① ②{success=connect(); ③if(success==-1){ ④throw new TimedOutException(); ⑤} ⑥}
A.public void method()
B.public void method()throws Exception
C.public void method()throw TimedOutException
D.publicthrowTimedOutExceptionvoidmethod()
第4题:
static void test() throws RuntimeException { try { System.out.print(”test “); throw new RuntimeException(); } catch (Exception ex) { System.out.print(”exception “); } } public static void main(String[] args) { try { test(); } catch (RuntimeException ex) { System.out.print(”runtime “); } System.out.print(”end “); } What is the result?()
第5题:
阅读下面程序 public class Test implements Runnable { public static void main(String[] args) { ______ t.start(); } public void run() { System.out.println("Hello!"); } } 程序中下画线处应填入的正确选项是
A.Test t=new Test();
B.Thread t=new Thread();
C.Thread t=new Thread(new Test());
D.Test t=new Thread();
第6题:
已知如下代码: public class Test long a[]=new long[10] public static void main (String args[]{ System.out.println(a[6];} 以下( )语句是正确的。
A.Output is null.
B.When running,some error will occur.
C.When compile,some error will occur.
D.Output is 0.
第7题:
给出下列的不完整的方法,则哪个声明可以被加入①行完成此方法的声明?( ) ① ② {success=connect(); ③ if(success==-1){ ④ throw new TimedOutException(); ⑤ } ⑥ }
A.public void method()
B.public void method()throws Exception
C.public void method()throw TimedOutException
D.public throw TimedOutException void method()
第8题:
阅读下面程序 public class Test implements Runnable{ public static void main(String[]args){ _______________________________________; t. start(); } public void mR(){ System. out. println("Hello!"); }} 在程序下画线处填入正确选项是
A.Test t=flew Test()
B.Thread t=new Thread();
C.Thread t=new Thread(new Test());
D.Test t=new Thread();
第9题:
( 11 )请在下列程序的空白处,填上适当的内容:
Import java. awt. *;
Import java. util. *;
Class BufferTest{
Public static void main(string args[])
Throws IOException{
FileOutputStream unbuf=
new FileOutputStream( “ test.one ” ) ;
BufferedOutputStream buf=
new 【 11 】 (new FileOutputStream( “ test.two ” ));
System.out.println
( “ write file unbuffered: ” + time(unbuf) + “ ms ” );
System.out.println
( “ write file buffered: ” + time(buf) + “ ms ” );
}
Static int time (OutputStream os)
Throws IOException{
Date then = new Date();
for (int i=0; i<50000; i++){
os.write(1);
}
}
os.close();
return(int)(()new Date()).getTime() - then.getTime());
}
第10题:
public class X { public static void main(String [] args) { try { badMethod(); System.out.print(“A”); } catch (Exception ex) { System.out.print(“C”); } finally { System.out.print(“B”); } System.out.print(“D”); } public static void badMethod() { throw new Error(); } } What is the result?()