Question 95
Given:
10. class MakeFile {
11. public static void main(String[] args) {
12. try {
13. File directory = new File(“d”)
14. File file = new File(directory,”f”)
15. if(!file.exists()) {
System.out.println("file.exists() is true");//自添的测试代码,题目没有
16. file.createNewFile();
17. }
18. } catch (IOException e) {
System.out.println("file.exists() is false");//自添的测试代码,题目没有
19. e.printStackTrace
20. }
21. }
22. }
The current directory does NOT contain a directory named “d.”
Which three are true? (Choose three.) A. Line 16 is never executed.
B. An exception is thrown at runtime.
C. Line 13 creates a File object named “d”
D. Line 14 creates a File object named “f”
E. Line 13 creates a directory named “d” in the file system
F. Line 16 creates a directory named “d” and a file “f” within it in
file system.
G. Line 14 creates a file named “f” inside of the directory named “d”
the file system.
Answer: BCD
我在eclipse里测试了一下,怎么输出是:
file.exists() is true
file.exists() is false
java.io.IOException: 系统找不到指定的路径。
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(Unknown Source)
at t.main(t.java:9)
问题一:有true又有false,如何是这样???
问题二:谁能清楚地解释一下各个选项的对错啊?谢谢。。
Given:
10. class MakeFile {
11. public static void main(String[] args) {
12. try {
13. File directory = new File(“d”)
14. File file = new File(directory,”f”)
15. if(!file.exists()) {
System.out.println("file.exists() is true");//自添的测试代码,题目没有
16. file.createNewFile();
17. }
18. } catch (IOException e) {
System.out.println("file.exists() is false");//自添的测试代码,题目没有
19. e.printStackTrace
20. }
21. }
22. }
The current directory does NOT contain a directory named “d.”
Which three are true? (Choose three.) A. Line 16 is never executed.
B. An exception is thrown at runtime.
C. Line 13 creates a File object named “d”
D. Line 14 creates a File object named “f”
E. Line 13 creates a directory named “d” in the file system
F. Line 16 creates a directory named “d” and a file “f” within it in
file system.
G. Line 14 creates a file named “f” inside of the directory named “d”
the file system.
Answer: BCD
我在eclipse里测试了一下,怎么输出是:
file.exists() is true
file.exists() is false
java.io.IOException: 系统找不到指定的路径。
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(Unknown Source)
at t.main(t.java:9)
问题一:有true又有false,如何是这样???
问题二:谁能清楚地解释一下各个选项的对错啊?谢谢。。
解决方案 »
- java的mina框架做聊天室服务器,怎么广播聊天信息。
- 我觉得java最大的弊端:没有拷贝构造方法,大家同意吗?我觉得应该有
- 通过Vector向JTree中加节点,源代码已贴可运行,有个奇怪问题
- 如何获取系统默认类加载器已加载的类和接口?
- 请问怎么实现JAVA调用视频头的录象功能?
- 救命啊,插入数据到Access,结果没反应,数据没用增加
- JNI 本地接口调用C++ 方法时,CDC HDC HWND 这些参数怎么转换啊 ? 急!
- 如何用JDBC连接SQL Server 2000的本地数据库?
- 问:为何右边的值无法赋给左边?(高分!)
- 新人入坑,
- Object value == null?????
- JATBLE排序后 VIEW和MODEL不一致
2. A.16行肯定执行了,只不过执行的时候抛出了异常。
B.参考A。
C.D.Java基础,你是看不懂英文还是?
E.只new了对象,并未在文件系统中真正创建。
F.由于上层文件夹不存在,创建不成功,抛出了异常,故F错误。
G.参考E.F,没有创建成功。