单选题在J2EE中,如果去编译并运行下面的代码,在这里假定在当前目录下没有Hello.txt文件: import java.io.*; public class Mine { public static void main(String argv[]){ Mine m=new Mine(); System.out.println(m.amethod()); } public int amethod() { try { FileInputStream dis=new FileInputStream("Hello.txt"); } catch (FileNotFoundException fne) { System.out.println("No such file found"); return -1; } catch(IOException ioe) { } finally { System.out.println("Doing finally"); } return 0; } } 结果会输出()。ANo such file foundBNo such file found -1CNo such file found doing finally -1D0
单选题
在J2EE中,如果去编译并运行下面的代码,在这里假定在当前目录下没有Hello.txt文件: import java.io.*; public class Mine { public static void main(String argv[]){ Mine m=new Mine(); System.out.println(m.amethod()); } public int amethod() { try { FileInputStream dis=new FileInputStream("Hello.txt"); } catch (FileNotFoundException fne) { System.out.println("No such file found"); return -1; } catch(IOException ioe) { } finally { System.out.println("Doing finally"); } return 0; } } 结果会输出()。
A
No such file found
B
No such file found -1
C
No such file found doing finally -1
D
0
参考解析
解析:
暂无解析
相关考题:
(11 )下面程序运行时输出结果为C:\Program Files is a directory请将程序补充完整。import Java.io.*;public class DirTest{public static void main(String[] args){File myDir = new File( " C:/Program Files/ " );System.out.println(myDir + ( 【 11 】 .isDirectory() ? " is " : " is not " ) + " a directory. " );}}
下列代码的编译或执行结果是______。public class MyVal{puhlic static void main(String args[]){MyVal m=new MyVal();m.aMethod();}public void aMethod(){boolean b[]=new Boolean[5];System.out.println(b[0]);}A) 1B) nullC) 0D) 编译错误A.B.C.D.
执行下面的程序段,输出结果为______。public class Q{public static void main(String argvr)){int anar[]=new int[5];System.out.println(anar[0]);}}
阅读下列代码Public class Person{Static int arr[ ] = new int (10);Public static void main (String args ) {System.out.println(arr[9]);}}该代码运行的结果是A )编译时将产生错误B )编译时正确,运行时将产生错误C )输出 0D )输出空
下列程序的执行结果是 ( ) public class Test { public int aMethod() { satic int i=0; i++; System.out.println(i); } public static void.main(String args[]) { Test test=new Test(); test.aMethod(); }A.编译错误B.0C.1D.运行成功,但不输出
如下两个源程序文件,分别编译后,运行Example.class文件,运行结果为______。AB.java文件代码如下;package test;public class AB{int a=60;public void show(){System.out.println(”a=”+a);}Example.java文件代码如下:import test.AB;class Example{public static void main(String args[]){AB bj=new AB();obj.show();}}
下列代码的执行结果是public class Test{ public int aMethod(){ static int i=0; i++; System.out.println(i); } public static void main(String args[]){ Test test= new Test(); test. aMethod(); }}A.编译错误B.0C.1D.运行成功,但不输出
阅读下面程序 public class My Val{ public static void main(String args[]){ My Val m=new My Val(); m. amethod(); } public void amethod(){ boolean b[]=new Boolean[5]; } } 程序编译或运行结果是A.1B.nullC.D.编译不能过
运行下列程序的结果是 ( ) abstract class MineBase { abstract void amethod(); static int i; } public class Mine extends MineBase { public static void main(String argv[]){ int[]ar=new int[5]; for(i=0;i<ar.length;i++) System.out.println(ar[i]);A.打印5个0B.编译出错,数组ar[]必须初始化C.编译出错,Mine应声明为abstractD.出现IndexOutOfBoundes的例外
下列程序创建了一个线程并运行,横线处应填入的正确代码是( )。 public class Try extends Thread{ public static void main(String args[]){ Thread t=new Try; ; } public void runf System.out.println(”Try!"); } }A.t.startB.t.classC.t.threadD.t.static
下列代码的编译或执行结果是( )。 public class Myval{ public static void main(string args[]){ MyVal m=new MyVal; aMethod; } public void aMethod{ boolean b[]=new Boolean[5]; System.OUt.println(b[0]); } }A.1B.nullC.0D.编译错误
下列代码的执行结果是( )。public class Test{public int aMethod( ){static int i=0;i++;System.out.println(i):}public static void main (String args[]){Trest test=new Test ( );test aMethod( ):}}A.编译错误B.0C.1D.运行成功,但不输出B.C.D.
阅读下面程序 public class MyVal { public static void main(String[]args) { MyVal m=new MyVal(); m.amethod(); } public void amethod() { boolean b[]=new Boolean[5]; } } 程序编译或运行的结果是A.1B.nullC.""D.编译不通过
下列代码实现从文件file.dat中读出第5个字节到变量c中,横线处应该填入下列项中的______。 import java.io.*; public class exl5 { public static void main(String[] args) { try System.out.println((char)c); catch(Exception e) { e.printStackTrace(); } } }A.FileInputStream in = new FileInputStream("chl/file.dat"); in.skip(4); int c = in.read();B.FileInputStream in = new FileInputStream("chl/file.dat"); in.skip(5); int c = in.read();C.Fi2eInputStream in = new FileInputStream("file.dat"); int c = in.read();D.RandomAccessFile in = new RandomAccessFile ("chi/file. dat "); in.skip (4); int c = in.readByte();
以下代码的调试结果?public class Q {public static void main(String argv[]) {int anar[]= new int[5];System.out.println(anar[0]);}} A. 编译错误:anar 在引用前未初始化。B. nullC. 0D. 5
以下的程序的调试结果为?public class MyAr{public static void main(String argv[]) {MyAr m = new MyAr();m.amethod();}public void amethod(){static int i;System.out.println(i);}} A. 输出结果为 0B. 运行出错C. 输出结果为 nullD. 编译错误
以下程序的编译和运行结果为?abstract class Base{abstract public void myfunc();public void another(){System.out.println("Another method");}}public class Abs extends Base{public static void main(String argv[]){Abs a = new Abs();A.amethod();}public void myfunc(){System.out.println("My Func");}public void amethod(){myfunc();}}A.输出结果为 My FuncB.编译指示 Base 类中无抽象方法C.编译通过,但运行时指示Base 类中无抽象方法D.编译指示Base 类中的myfunc方法无方法体,没谁会喜欢该方法。
以下的程序的调试结果为public class Scope{int i;public static void main(String argv[]){Scope s = new Scope();s.amethod();}public static void amethod(){System.out.println(i);}} A. 输出结果为:0B. 无输出C. 编译错误D. 输出null
以下程序的调试结果为?class Base{public final void amethod(){System.out.println("amethod");}}public class Fin extends Base{public static void main(String argv[]){Base b = new Base();b.amethod();}} A.编译指示带有final 方法的类自己必须定义为finalB.编译指示不能继承含有final 方法的类C.运行错误,原因是Base类没有定义为final类D.运行输出 amethod
以下的程序的调试结果为?public class As{int i = 10;int j;char z= 1;boolean b;public static void main(String argv[]){As a = new As();A.amethod();}public void amethod(){System.out.println(j);System.out.println(b);}}A.输出0 和falseB. 输出0 和trueC. 编译错误,b 未初始化D. 编译错误, z 必须赋字符值
下列程序创建了一个线程并运行,请在下划线处填入正确代码。public class Try extends Thread{public static void main(String args[]){Threadt=new Try();【 】;}public void run(){System.out.println(“Try!”);}}
public class Test { public static void aMethod() throws Exception { try { throw new Exception(); } finally { System.out.println(“finally”); } } public static void main(String args[]) { try { aMethod(); } catch (Exception e) { System.out.println(“exception”); } System.out.println(“finished”); } } What is the result?() A、 finallyB、 exception finishedC、 finally exception finishedD、 Compilation fails.
在J2EE中,如果去编译并运行下面的代码,在这里假定在当前目录下没有Hello.txt文件: import java.io.*; public class Mine { public static void main(String argv[]){ Mine m=new Mine(); System.out.println(m.amethod()); } public int amethod() { try { FileInputStream dis=new FileInputStream("Hello.txt"); } catch (FileNotFoundException fne) { System.out.println("No such file found"); return -1; } catch(IOException ioe) { } finally { System.out.println("Doing finally"); } return 0; } } 结果会输出()。 A、No such file foundB、No such file found -1C、No such file found doing finally -1D、0
public class Test { public int aMethod() { static int i = 0; i++; return i; } public static void main (String args[]) { Test test = new Test(); test.aMethod(); int j = test.aMethod(); System.out.println(j); } } What is the result?() A、 0B、 1C、 2D、 Compilation fails.
单选题下列代码的编译或执行结果是( )。public class MyVal{ public static void main(String args[]){ MyVal m = new MyVal(); m.aMethod(); } public void aMethod(){ boolean b[] = new Boolean[5]; System.out.println(b[0]); }}A1BnullC0D编译错误
单选题public class Test { public int aMethod() { static int i = 0; i++; return i; } public static void main (String args[]) { Test test = new Test(); test.aMethod(); int j = test.aMethod(); System.out.println(j); } } What is the result?()A 0B 1C 2D Compilation fails.
单选题public class Test { public static void aMethod() throws Exception { try { throw new Exception(); } finally { System.out.println(“finally”); } } public static void main(String args[]) { try { aMethod(); } catch (Exception e) { System.out.println(“exception”); } System.out.println(“finished”); } } What is the result?()A finallyB exception finishedC finally exception finishedD Compilation fails.