Given that the current directory is empty, and that the user has read and write permissions, and the following:
1. import java.io.*;
2. public class DOS {
3. public static void main(String[] args) {
4. File dir = new File("dir");
5. dir.mkdir();
6. File f1 = new File(dir, "f1.txt");
7. try {
8. f1.createNewFile();
9. } catch (IOException e) { ; }
10. File newDir = new File("newDir");
11. dir.renameTo(newDir);
12. }
13. }
Which statement is true?
A. Compilation fails.
B. The file system has a new empty directory named dir.
C. The file system has a new empty directory named newDir.
D. The file system has a directory named dir, containing a file f1.txt.
E. The file system has a directory named newDir, containing a file f1.txt.
Solution : E
11 line 에 dir.renameto(newDir)를 통해 이름을 재정의 합니다 . 그리고 6line에서 "f1.txt"을 지정하여 새로운 인스턴스를 생성한 것을 확인 하실 수있습니다
'자격증 > OCJP_ExamA' 카테고리의 다른 글
QUESTION 32 (0) | 2018.07.01 |
---|---|
QUESTION 31 (0) | 2018.07.01 |
QUESTION 30 (0) | 2018.07.01 |
QUESTION 29 (0) | 2018.07.01 |
QUESTION 28 (0) | 2018.07.01 |
#IT #먹방 #전자기기 #일상
#개발 #일상