选择题 18.  给定一个Java程序的main方法的代码片段如下:
    try
    {
    PrintWfiter out=new PrintWriter(new FileOutputStream("d:/a.txt"));
    String name="chen";
    out.print(name);
    }
    catch(Exception e)
    {
    System.out.println("文件没有发现!");
    }
    假如d目录下不存在a.txt文件,现运行该程序,下面的结果正确的是______。
【正确答案】 A
【答案解析】 由于文件不存在,因此,在调用new FileOutputStream("d:/abc.txt")时,会抛出FileNotFoundException异常,这个异常是Exception的子类,能匹配Exception从而执行catch块的代码输出“文件没有发现!”。所以,选项A正确。