String name= File.getParentName(“file.txt”);
String name= (new File(“file.txt”)).getParent();
String name = (new File(“file.txt”)).getParentName();
String name= (new File(“file.txt”)).getParentFile();
Directory dir=(new File (“file.txt”)).getParentDir(); String name= dir.getName();
第1题:
A.OutputStreamout=newFileOutputStream(“file.txt”);
B.OutputStreamout=newFileOutputStream(“file.txt”,“append”);
C.FileOutputStreamout=newFileOutputStream(“file.txt”,true);
D.FileOutputStreamout=newFileOutputStream(newfile(“file.txt”));
E.OutputStreamout=newFileOutputStream(newFile(“file.txt”)true);
第2题:
A.Stringname=File.getParentName(“file.txt”);
B.Stringname=(newFile(“file.txt”)).getParent();
C.Stringname=(newFile(“file.txt”)).getParentName();
D.Stringname=(newFile(“file.txt”)).getParentFile();
E.Directorydir=(newFile(“file.txt”)).getParentDir();Stringname=dir.getName();
第3题:
对于如下程序: #include
第4题:
下列语句正确的有()
第5题:
为文件c:/java/example/file.txt建立File对象file1可以采用()语句序列。
第6题:
Which two create an InputStream and open file the “file.txt” for reading? ()
第7题:
The file “file.txt” exists on the file system and contsins ASCII text. Given: try { File f = new File(“file.txt”); OutputStream out = new FileOutputStream(f, true); } catch (IOException) {} What is the result?()
第8题:
InputStream in=new FileReader(“file.txt”);
InputStream in=new FileInputStream(“file.txt”);
InputStream in=new InputStreamFileReader (“file.txt”, “read”);
FileInputStream in=new FileReader(new File(“file.txt”));
FileInputStream in=new FileInputStream(new File(“file.txt”));
第9题:
第10题:
<%@ include file=”head.jsp”%>
<% String url=”head.jsp”;%><%@ include file=”url”%>
<%@ include file=”head.jsp”?name=”lovo”%>
<%String companyName=”lovo”;%>%@include file”head.jsp”?name=‟companyName”%
第11题:
OutputStream out=new FileOutputStream(“file.txt”);
OutputStream out=new FileOutputStream(“file.txt”, “append”);
FileOutputStream out=new FileOutputStream(“file.txt”, true);
FileOutputStream out=new FileOutputStream(new file(“file.txt”));
OutputStream out=new FileOutputStream(new File(“file.txt”)true);
第12题:
The code does not compile.
The code runs and no change is made to the file.
The code runs and sets the length of the file to 0.
An exception is thrown because the file is not closed.
The code runs and deletes the file from the file system.
第13题:
A.OutputStreamout=newFileOutputStream(“file.txt”); Out.writeBytes(“/n”);
B.OutputStreamos=newFileOutputStream(“file.txt”,true); DataOutputStreamout=newDataOutputStream(os);out.writeBytes(“/n”);
C.OutputStreamos=newFileOutputStream(“file.txt”); DataOutputStreamout=newDataOutputStream(os);out.writeBytes(“/n”);
D.OutputStreamos=newOutputStream(“file.txt”,true); DataOutputStreamout=newDataOutputStream(os);out.writeBytes(“/n”);
第14题:
阅读下列说明和Java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。
【说明】
现欲构造一文件/目录树,采用组合(Composite)设计模式来设计,得到的类图如6—8所示:
【Java代码】
import JavA.util.ArrayList;
import JavA.util.List;(1)class AbstractFile{
protected String name;
public void printName(){System.out.println(name);}
public abstract boolean addChild(AbstractFile file);
public abstract boolean removeChild(AbstractFile file);
public abstract ListgetChildren {};
}
class File extends AbstractFile{
public File(String name)(this.name=name;}
public boolean addChild(AbstractFile file){return false;}
public boolean removeChild(AbstractFile file){return false;}
public ListgetChildren(){return (2) ;)
}
clasS Folder extends AbstractFile{
private ListchildList;
public Folder(String name){
thiS.name=name;
this.childList=new ArrayList{};
}
public boolean addChild(AbstractFile file){return childList.add(file);}
public boolean removeChild(AbstractFile file){return childList.remove(file);
public (3)getChildren(){return (4) ;)
}
public class Client{
public static void main(String[]args){
//构造一个树形的文件/目录结构
AbstractFile rootFolder=new Folder(“C:\”’);
AbstractFile compositeFolder=new Folder(”composite”);
AbstractFile windowsFolder=new Folder(”windows”);
AbstractFile file=new File(”TestComposite.java”);
rootFOlder.addChild (compositeFolder);
rootFolder.addChiid(windowsFolder);
compositeFolder.addChild(file);
//打印目录文件树
printTree(rootFolder);
}
private static void printTree(AbstractFile ifile){
ifile.PrIntName();
Listchildren:ifile.getChildren ();
if(chiidren==null)return;
for(AbstractFile file:children){(5) ;
}
}
}
该程序运行后输出结果为:
C:\
composite
TestComposite.java
Windows
第15题:
创建一个向文件“file.txt”追加内容的输出流对象的语句有()。
第16题:
Which two construct an OutputSream that appends to the file “file.txt”? ()
第17题:
Which of the following commands changes a file characteristic so that it cannot be seen with astandard directory query? ()
第18题:
Which gets the name of the parent directory file “file.txt”?()
第19题:
What writes the text “ ” to the end of the file “file.txt”?()
第20题:
OutputStream out= new FileOutputStream (“file.txt”); Out.writeBytes (“ /n”);
OutputStream os= new FileOutputStream (“file.txt”, true); DataOutputStream out = new DataOutputStream(os); out.writeBytes (“ /n”);
OutputStream os= new FileOutputStream (“file.txt”); DataOutputStream out = new DataOutputStream(os); out.writeBytes (“ /n”);
OutputStream os= new OutputStream (“file.txt”, true); DataOutputStream out = new DataOutputStream(os); out.writeBytes (“ /n”);
第21题:
FileOutputStream out=new FileOutputStream(“file.txt”,true);
OutputStream out=new FileOutputStream(“file.txt”,“append”);
OutputStream out=new FileOutputStream(“file.txt”);
FileOutputStream out=new FileOutputStream(new file(“file.txt”));
OutputStream out=new FileOutputStream(new File(“file.txt”),true.;
第22题:
String name= File.getParentName(“file.txt”);
String name= (new File(“file.txt”)).getParent();
String name = (new File(“file.txt”)).getParentName();
String name= (new File(“file.txt”)).getParentFile();
Directory dir=(new File (“file.txt”)).getParentDir(); String name= dir.getName();
第23题:
attrib file.txt +h
attrib file.txt +r
ren file.txt
attrib file.txt +s
第24题:
File file 1=new File(“c://java//example//file.txt”)
String path=”c:/java/example/”Filefile1=newFile(path,”oldfile.txt”)
File dir 1=new File(“c://java//example”)Filefile1=newFile(dir1,”oldfile.txt”)
File file 1=new File(“c:/java//example/file.txt”)