SCJP 1.6版考題 151

出自 陳富國維基館
於 2013年3月30日 (六) 02:57 由 Ikk (對話 | 貢獻) 所做的修訂 (新頁面: Given that the current directory is empty, and that the user has read and write privileges to the current directory, and the following: 1. import java.io.*; 2. public class Maker{...)
(差異) ←上個修訂 | 最新修訂 (差異) | 下個修訂→ (差異)
前往: 導覽搜尋
Given that the current directory is empty, 
and that the user has read and write privileges to the current directory, and the following:
1. import java.io.*;
2. public class Maker{
3.   public static void main(String args){
4.     File dir = new File("dir");
5.     File f = new File(dir, "f");
6.   }
7. }

Which statement is true?
 A. Compilation fails.
 B. Nothing is added to the file system.
 C. Only a new file is created on the file system.
 D. Only a new directory is created on the file system.
 E. Both a new file and a new directory are created on the file system.

解答


Ans: B

解說:

4/5行只是宣告目錄、檔案
真正建立檔案的方法是createNewFile(),例子如145