黑马程序员技术交流社区

标题: 经典题型 [打印本页]

作者: leaf168    时间: 2015-10-11 23:33
标题: 经典题型
29.        如果在当前目录下不存在Hello.txt 文件,试图编译和运行下面代码会输出什么C
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

作者: Frank0601    时间: 2015-10-13 22:31
会报警告,catch语句无法访问。




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2