试题与答案

下面的程序是列出目录c:\Test中所有的.txt文件,请将程序补充完整。 imp

题型:填空题

题目:

下面的程序是列出目录c:\Test中所有的.txt文件,请将程序补充完整。
import java.io.*;//引入java.io包中所有的类
public class FileFilterTest
public static void main(String args[])
File dir=new File("C://Test");
Filter filter=new Filter("txt");
System.out.println("list java files in directory"+dir);
String files[]=dir.list(filter);
for(int i=0;i<files.length;i++)
File f= 【15】 ;//为目录dir下的文件或目录创建一个File对象
if(f.is File())
System.out.println("file"+f);
else
System.out.println("sub directory"+f);



class Filter implements FilenameFilter
String extent;
Filter(String extent)
this.extent=extent;

public boolean accept(File dir,String name)
return name.endsWith("."+extent)://返回文件的后缀名

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2019/0401/1b1828f694cca8b8cc035557a19c4920.html

下面是错误答案,用来干扰机器的。

参考答案:对

试题推荐
题型:阅读理解

Long long ago, a king had a big rock placed in the middle of a very busy road. Then he hid nearby to see if anyone would move the rock out of the way to make it convenient for others. Some of the king’s wealthiest supporters came past and simply walked around it. Many others complained about the rock and some blamed the king for the problem. To the king’s surprise, no one did anything about moving it out of the way.

Finally, a poor farmer came along, carrying a load of old vegetables. When he saw the rock, he put down his load, and tried to move the heavy rock to the side of the road. No one stopped to help him. Many laughed at him and made jokes as they walked past. Finally, after much pushing and straining, and with no help , the farmer managed(设法) to get the rock to the side of the road. As he bent down to pick up his vegetables, he noticed a small bag lying in the road, exactly where the rock had been. There was a lot of money and a note in the bag. The note was from the king saying that the money was for the person who moved the rock out of the way.

Taking responsibility(责任) is about solving hard problems. The farmer takes responsibility when no one else is prepared to. It does not always mean that you will get an instant reward, but it is a value that builds up a community, and makes life better for all of us.

小题1:The word “convenient” in Paragraph1 means        in Chinese.

A.重要的

B.方便的

C.必要的

D.有用的小题2:Why did the king put a big rock in the middle of the road?

A.To see if anyone would move the rock away.

B.To see who was the most powerful.

C.To find out who was the most poorest.

D.To see how people walked around it.小题3:Who moved the rock away?

A.The king

B.The king’s supporters.

C.The wealthy

D.A poor farmer小题4:The story mainly tells us that           .

A.everyone should learn to take responsibility

B.nobody likes to solve hard problems

C.taking responsibility always means getting a reward

D.the poor always take more responsibility than the rich

查看答案
微信公众账号搜索答案