以下对File类的public boolea isFile()方法的描述,哪个是正确的?()A、判断该File对象所对应的是否是文件。B、判断该File对象所对应的是否是目录。C、返回文件的最后修改时间。D、在当前目录下生成指定的目录

以下对File类的public boolea isFile()方法的描述,哪个是正确的?()

  • A、判断该File对象所对应的是否是文件。
  • B、判断该File对象所对应的是否是目录。
  • C、返回文件的最后修改时间。
  • D、在当前目录下生成指定的目录

相关考题:

【C++代码】#include list#include iostream#include stringusing namespace std;class AbstractFile{protected:string name; //文件或目录名称public:void printName(){coutname;} //打印文件或目录名称virtual void addChild(AbstractFile *file)=0; //给一个目录增加子目录或文件}virtual void removeChild(AbstractFile *file)=0; //删除一个目录的子目录或文件virtual listAbstractFile* *getChildren()=0; //获得一个目录的子目录或文件};class File:public AbstractFile{public:File(string name) {(1) = name;}void addChild(AbstractFile *file){return;}void removeChild(AbstractFile *file){return;}(2) getChildren(){return (3) ;}};class Folder :public AbstractFile{private:list AbstractFile* childList: //存储子目录或文件public:Folder(string name){ (4) name;}void addChild(AbstractFile*file){childList.push_back(file);}void removeChild(AbstractFile*file){childList.remove(file);}listAbstractFile**getChildren(){return (5) ;}};void main(){//构造一个树形的文件/目录结构AbstractFile *rootFolder=new Folder("c:\\ ");AbstractFile*compositeFolder=new Folder("composite");AbstractFile *windowsFolder=new Folder("windows");AbstractFile*file=new File("TestCompositejava");rootFolder-addChild(compositeFolder);rootFolder-addChild(windowsFolder);compositeFolder-addChild(file);}

【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(AbstractF ile file);public abstract ListAbstractFile getChildren();}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 ListAbstractFile getChildren(){return (2) ;}}class Folder extends AbstractFile{private List AbslractFile childList;public Folder(String name){this.name=name;this.childList=new ArrayListAbstractFile();}public boolean addChild(AbstractFile file) { return childList.add(file);}public boolean removeChild(AbstractFile file){return childList.remove(file);}public (3) AbstractFile 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.addChild(windowsFolder);compositeFolder.addChild(file) ;//打印目录文件树printTree(rootFolder);}private static void printTree(AbslractFile ifile){ifile.printName();List AbslractFile children=ifile.getChildreno:if(children==null) return;for (AbstractFile file:children) {(5) ;}}}该程序运行后输出结果为:c:\compositeTestComposite.javaWindows

以下属于java.io包中的非流类的有()。A.File类B.ReaderC.InputStreamD.FileNameFilert

下列叙述中,错误的是A.File类能够存储文件B.File类能够读写文件C.File类能够建立文件D.File类能够获取文件目录信息

下面程序运行时输出的结果为C:\Program Files is a directory.将程序补充完整。Import java.io.*;public class DirTest {public static void main(String[] args) {File myDir=Flew File("C:/Program Files/");System.out.println(myDir+(______.isDirectory()?"is":"is not")+"a directory.");}}

(11 )下面程序运行时输出结果为C:\Program Files is a directory请将程序补充完整。import Java.io.*;public class DirTest{public static void main(String[] args){File myDir = new File( " C:/Program Files/ " );System.out.println(myDir + ( 【 11 】 .isDirectory() ? " is " : " is not " ) + " a directory. " );}}

下面哪项不是File类的构造方法() A、File(StringfileName)B、File(Filedirectory)C、File(Stringdirectory,StringfileName)D、File(Filedirectory,StringfileName)

访问修饰符public拥有最高的访问级别,类的public成员所有类的成员都可以访问。() 此题为判断题(对,错)。

下面程序的运算结果是()。includeusing namespace std;class A{public:virtual void f 下面程序的运算结果是( )。 #include<iostream> using namespace std; class A { public: virtual void fun()=0; }; class B:public A } public: void fun() {cout<<"new file"<<" ";} }; class C:public A { public: void fun() { cout<<"open file"<<" ";} }; void main() { A a, * p; B b;C c; p=c; p->fun(); p=b; }A.new file open fileB.new file new fileC.编译出错D.open file new file

下面叙述错误的是( )A.对基类成员的访问能力在private派生类中和public派生类中是相同的B.基类的private成员在public派生类中不可访问C.基类中的public成员在protected派生类中是protected的D.基类中的public成员在protected派生类中仍然是public的

阅读下列说明和c++代码,将应填入 (n) 处的字句写在答题纸的对应栏内。【说明】现欲构造一文件/目录树,采用组合(Composite)设计模式来设计,得到的类图如6—7所示:【c++代码】include1istincludeincludeusing namespace std;class AbstractFile{protected:string name;//文件或目录名称public:void printName(){cout*getChildren()=0; //获得一个目录的子目录或文件};class File:public AbstractFile{public:File(string name){ (1) =name;)void addChild(AbstractFile*file){return ;)void removeChiid(AbstractFile*file){return;}(2) getChildren(){return ( 3 ) ;}};class Folder:public AbstractFile{private:listchildList; //存储子目录或文件public:Folder(string name){ (4) =name;}void addChild(AbstractFile*file){childList.push back(file);}void removeChiid(AbstractFile*file)(chiidList.remove(file);}list*getChildren(){return (5) ;)};voidmain(){//构造一个树形的文件/目录结构AbstractFile*rootFolder=new Folder(“C:\\”);AbstractFile*compositeFolder=flew Folder(”composite”);AbstractFile*windowsFolder=new Folder(”windows”);AbstractFile*file=new File(”TestComposite.java”);rootFolder-addChild(compositeFolder);rootFolder-addChild (windowsFolder);compositeFolder-addChiid(file);)

阅读下列说明和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:\compositeTestComposite.javaWindows

JAVA File类执行下面这段程序为什么会出现异常 File file=new File(args[0]); 这句是什么意思?? importjava.io.*;importjava.util.*;publicclassFileClass{/***@paramargs*/publicstaticvoidmain(String[]args){//TODOAuto-generatedmethodstubtry{Filefile=newFile(args[0]);System.out.println(args[0]+"文件");if(file.isFile()){//是否为文件System.out.print(file.canRead()?"可读":"不可读");System.out.print(file.canWrite()?"可写":"不可写");System.out.print(file.length()+"字节");//注意不能调用数组类型File[]的length()例:File[]files=file.listFiles();不可以这么调用filess.length()}else{//列出所有文件及目录File[]files=file.listFiles();ArrayListFilefileList=newArrayListFile();for(inti=0;ifiles.length;i++){//先列出目录if(files[i].isDirectory()){//是否为目录//取得路径名System.out.println("路径"+"["+files[i].getPath()+"]");}else{//文件先存入fileList,待会再列出fileList.add(files[i]);}}//列出文件for(Filef:fileList){System.out.println(f.toString());}System.out.println();}}catch(ArrayIndexOutOfBoundsExceptione){System.out.println("using:javaFileDemopathname");}}}结果:using:javaFileDemopathname是不是创建的对象所代表的文件没有被创建成功

下面程序的结果是 ______。includeclass A{ public:virtual voidfun()=0{};};class 下面程序的结果是 ______。 #include<iostream.h> class A{ public: virtual void fun()=0{}; }; class B:public A{ public: void fun () {cout<< "new file" ;} }; class C: public A{ public: void fun (){cout<<"open file"<< " " } }; class D: public A{ public: void fun () {cout<< "save file\n" ;} }; void main() { A a,*p; B b; C c; D d; p=c; p->fun (); p=b; p->fun (); p=d; p->fun(); }A.new file open file save fileB.new file new file new fileC.编译出错D.open file new file save file

以下对File类的public boolea isFile()方法的描述,哪个是正确的? A.判断该File对象所对应的是否是文件B.判断该File对象所对应的是否是目录C.返回文件的最后修改时间D.在当前目录下生成指定的目录

在下列程序的横线处填入正确的语句,实现RandomAccessFile类使用。 package ch1; import java. io. *; public class ex27 { public static void main(String args[] ) { try { RandomAccessFile in = new in.close ( ); } catch (Exception e) { e.printStackTrace (); } } }A.RandomAccessFileC"ch1/file.dat", "read")B.RandomAccessFile("r", "ch1/file.dat")C.RandomAccessFile("ch1/file.dat" , "r")D.RandomAecessFile("read", "ch1/file.dat")

The type of carrier required to file a copy of freight tariffs would be the ______.A.Common carrierB.TrampC.Public vesselD.Bulk carrier

以下类中,()和()可以实现文件(File)服务。A、DirectoryB、PathC、FileD、DirectoryInfoE、FileInfo

对于类,其属性的可见性表示对类的外部世界的可见性,它有以下()选项A、公开(publiC.B、包内公开(packagE.C、保护(protecteD.D、私有(privatE.

public class test {  public static void main(String [] a) {  assert a.length == 1;  }  }  Which two will produce an AssertionError?()A、 java testB、 java -ea testC、 java test file1D、 java -ea test file1E、 java -ea test file1 file2F、 java -ea:test test file1

以下关于File类的叙述,哪两项正确?()A、File类位于java.io包中B、创建一个File类的实例将导致打开指定文件进行读写C、File实例不能用于封装目录D、File实例封装了指定文件的信息

File Output Stream类的父类是()A、FileB、File OutputC、Output StreamD、Input Stream

You work as a Web Developer at Certkiller.com. You make use of Microsoft ASP.NET 3.5 in orderto create a Web Site.  In a separate code file you create the following class:  public static class _Colors {  public static Color NormalActivityColor = Color.Green;  public static Color WarningActivityColor = Color.Yellow;  public static Color ErrorActivityColor = Color.Red;    public static Color GetRandomColor()  {  Random random = new Random((int)DateTime.Now.Ticks);  int randomArgbValue = random.Next();  Color color = Color.FromArgb(255, Color.FromArgb(randomArgbValue));  return color;  }  }  You need to ensure that the class is consumed by the Web Site. You have to configure the WebSite project.  What should you do?()A、You should add the file to the App_Code folder of the project.B、You should add a Register directive that will reference the file to every page that makes use ofthe class.C、This can be accomplished by referencing the file in the assemblies segment of the Web.configfile.D、This can be accomplished by referencing the file in the httpHandlers segment of the Web.configfile.

判断题Python标准库os中的方法isfile()可以用来测试给定的路径是否为文件。A对B错

多选题以下类中,()和()可以实现文件(File)服务。ADirectoryBPathCFileDDirectoryInfoEFileInfo

单选题Which method implementations will write the given string to a file named "file", using UTF8 encoding?()   IMPLEMENTATION a:   public void write(String msg) throws IOException {   FileWriter fw = new FileWriter(new File("file"));   fw.write(msg);   fw.close();   }   IMPLEMENTATION b:   public void write(String msg) throws IOException {   OutputStreamWriter osw =  new OutputStreamWriter(new FileOutputStream("file"), "UTF8");  osw.write(msg);   osw.close();   }   IMPLEMENTATION c:   public void write(String msg) throws IOException {  FileWriter fw = new FileWriter(new File("file"));   fw.setEncoding("UTF8");   fw.write(msg);   fw.close();  }   IMPLEMENTATION d:   public void write(String msg) throws IOException {  FilterWriter fw = FilterWriter(new FileWriter("file"), "UTF8");   fw.write(msg);  fw.close();   }   IMPLEMENTATION e:   public void write(String msg) throws IOException {   OutputStreamWriter osw = new OutputStreamWriter(  new OutputStream(new File("file")), "UTF8"  );   osw.write(msg);   osw.close();   }AImplementation a.BImplementation b.CImplementation c.DImplementation d.EImplementation e.

多选题public class test {  public static void main(String [] a) {  assert a.length == 1;  }  }  Which two will produce an AssertionError?()Ajava testBjava -ea testCjava test file1Djava -ea test file1Ejava -ea test file1 file2Fjava -ea:test test file1