错题1及原因,理解情况 Assume infile is a BufferedReader for a textfile and that the textfile is empty. What is returned from the message infile.readLine( ); ? A . 0 B . null C . a special character known as the End-of-file marker (EOF) D . none of the above, the message causes a NullPointerException to be thrown E . none of the above, the message causes a EndOfFileException to be thrown 正确答案: B 你的答案: E 我本来是依稀记得书上哪里好像看到一眼null,但是之后找不到了最后选了E,还是看书不仔细。readLine()方法返回与文件中下一个文本项相等的字符串。如果文件为空,则返回为null。
错题2及原因,理解情况 PrintWriter is a better output stream class that PrintStream because PrintWriter A . has both print and println methods and PrintStream only has print B . can output both byte and character streams and PrintStream can only output byte streams C . has error checking mechanisms as part of the class and PrintStream does not D . will not throw checked exceptions and PrintStream will E . all of the above 正确答案: C 你的答案: B 这个我确实当时不知道,稍微想了一下,所以错了。打印器类是一个编写器类,而打印流类是一个流类。主要的区别是打印器是专为文件设计的,因此错误检查机制不是打印流的一部分。
错题3及原因,理解情况 The following defines a new Exception called AnewException. public Exception ANewException { public ANewException(String message) { super(message); } } A . true B . false 正确答案: B 你的答案: A 感觉是没毛病的,应该是对的呀,自己想不出原因,看解析:定义几乎是正确的,但它必须定义一个类,而不是一个例外。异常是一个类,异常应该扩展异常。类定义的标头应该是公共类的辅助扩展异常。