单选题 运行下列程序时,若没有test.dat文件,则(  )。importJava.io.*;publicclassTestpublicstaticvoidmain(String[]args)tryRandomAccessFileraf=newRandomAccessFile("test.dat","r,");System.out.println("test.dat");catch(IOExceptionex)System.out.println("exception");
【正确答案】 A
【答案解析】在程序运行到RandomAccessFileraf=newRandomAccessFile(“test.dat”,“r”)这一行时,由于没有test.dat文件,抛出IOException异常,由下面的catch捕获,从而输出exception。IOException是当发生某种I/O异常时,抛出的异常。