重要提示: 请勿将账号共享给其他人使用,违者账号将被封禁!
查看《购买须知》>>>
找答案首页 > 全部分类 > 计算机类考试
搜题
网友您好, 请在下方输入框内输入要搜索的题目:
搜题
题目内容 (请给出正确答案)
[主观题]

请完成下列Java程序。程序的功能是显示用户在命令行方式下指定的任意驱动器文件夹的内容。 提示:pu

请完成下列Java程序。程序的功能是显示用户在命令行方式下指定的任意驱动器文件夹的内容。

提示:public string()list();//将文件夹中所有文件名保存在字符数组中返回。

注意:请勿改动main()主方法和其他已有的语句内容,仅在下划线处填入适当的语句。

源程序文件代码清单如下:

import java.io.*;

public class FindDirectories

{

public static void main(String args[])

{

if(args.length==0)

args=new String(){".."};

try

{

______;

String[] fileName=pathName.list();

for(int i=0;i<fileName.length;i++)

{

File f=new File(pathName.getPath(),fileName[i]);

if(______)

{

System.out.println(f.getCanonicalPath());

main(new String[]

{

f.getPath()

});

}

}

}

catch(IOException e)

{

e.printStackTrace();

}

}

}

查看答案
更多“请完成下列Java程序。程序的功能是显示用户在命令行方式下指定的任意驱动器文件夹的内容。 提示:pu”相关的问题

第1题

Class对象由Java【】自动生成。

Class对象由Java【 】自动生成。

点击查看答案

第2题

在程序中,DataPool是一个数据池,能存放一个血型数据,线程a和线程b负责向其中存放数据,一次只能有

一个线程向其中存放数据,数据放入DataPool以后,该线程随机休眠一段时间,让另外一个线程运行,请将程序补充完整。

注意:请勿修改main()主方法和其他已有语句内容,仅在横线处填入适当语句。

class PutData extends Thread

{

DataPool s;

int c;

String name;

public PutData(DataPool s,String name)

{

this.s=s;

this.name=name;

}

public void run()

{

for(int i=0;i<10000000;i++)

{

c=(int)(Math.random()*10);

s.setData(c);

System.out.println(name+":push"+c);

try

{

______((int) (Math.random()*1000));//休眠

}

catch(InterruptedException e)

{}

}

}

}

class DataPool

{

private int data=0;

public ______void setData(int d)

{

data=d;

}

}

public class simple

{

public static void main(String[] args)

{

DataPool s=new DataPool();

PutData a=new PutData(s,"Thread a");

PutData b=new PutData(s,"Thread b");

a.start();

b.start();

}

}

点击查看答案

第3题

以下程序中,使用适当的布局管理器,在Frame框的“North”位置添加一句提示信息,在“South”位置添加一

个单行文本框,在这个文本框中输入的内容将会显示在“Center”位置。运行结果如下图所示。

注意:请勿改动main()主方法和其他已有语句内容,仅在横线处填入适当语句。

import java.awt.*;

import java.awt.event.*;

public class Example2_6 extends Frame

{

public static void main(String [] argv)

{

Example2_6 frame. = new Example2_6("Example2_6");

frame, init ();

frame.setSize(300, 300);

frame, show ();

}

public Example2_6(String name)

{

super (name);

addWindowListener (new WindowAdapter ()

{ public void windowClosing(WindowEvent e)

{ __________;

}

} );

}

public void init()

{

setLayout (new ___________);

Label labelTitle = new Label("在文本框中输入字符串,可以在Frame. 中间显示");

Label showTextLabel = new Label();

TextField textField = new TextField("请在这里输入字符串");

textField.addActionListener (new AddStringListener(showTextLabel, textField) );

add("North", labelTitte);

add("Center", showTextLabel);

add("South", textField);

}

}

class AddStringListener implements ActionListener

{

Label label;

TextField textField;

public AddStringListener(Label label, TextField textField)

{

this. label = label;

this.textField = textField;

}

public void actionPerformed(ActionEvent e)

{

label, setText (textField. getText ());

}

}

点击查看答案

第4题

下列程序是整数除法计算的程序,要求在出现异常时,能抛出异常信息。 考虑两种异常: (1)输入非数字

下列程序是整数除法计算的程序,要求在出现异常时,能抛出异常信息。

考虑两种异常:

(1)输入非数字除数

(2)输入除法分母为零

该程序运行的三种结果状态如下:

(1)输入两个合法整数

(2)输入非数字除数

(3)输入除数为零

请将程序填写完整。

注意:不改动程序结构,不得增行或删行。

import java.awt.event.*;

public class ex3 extends ______implements ActionListener

{

private JTextField input1,input2, output;

private int number1,number2;

private double result;

public ex3()

{

______("示范异常");

Container c=getContentPane();

c.setLayout(new GridLayout(3,2));

c.add(new JLabe1("输入分子",SwingConstants.RIGHT));

input1=new JTextField(8);

c.add(input1);

c.add(new JLabe1("输入分母和回车",SwingConstants.RIGHT));

input2=new JTextField(8);

c.add(input2);

input2.addActionListener(this);

c.add(new JLabe1(”计算结果”,SwingConstants.RIGHT));

output=new JTextField();

c.add(output);

setSize(400,100);

show();

}

public void actionPerformed(ActionEvent e)

{

DecimalFormat precision3=new DecimalFormat("0.000");

output.setText("");//空的JTextField输出

try{

number1=Integer.parseInt(input1.getText());

number2=Integer.parseInt(input2.getText());

result=quotient(number1,number2);

______;

}

catch (NumberFormatException nfe)

{

______(this,"你必须输入两个整数","非法数字格式",

JOptionPane.ERROR_MESSAGE);

}

catch (Exception dbz)

{

______(this,"除法异常","除数为零",

JOptionPane.ERROR_MESSAGE);

}

}

//定义求商的方法,如遇除数为零时,能抛出异常。

public double quotient(int numerator,int denominator)

throws Exception

{

if(denominator= =0)

throw new Exception();

return(double) numerator/denominator;

}

public static void main(String args[])

{

Java3 app=new Java3();

app.addWindowListener(

new WindowAdapter(){

public void windowClosing(WindowEvent e)

{

e.getWindow().dispose();

System.exit(0);

}

}

);

}

}

点击查看答案

第5题

在程序中,使用适当的布局管理器,在Frame框的North位置添加一句提示信息,在South位置添加一个单行

文本框,在这个文本框中输入的内容将会显示在Center位置。运行结果如下图所示。

注意:请勿修改main()主方法和其他已有语句内容,仅在横线处填入适当语句。

import java.awt.*;

import java.awt.event.*;

public class simple extends Frame

{

public static void main(String[] args)

{

simple frame=new simple("simple");

frame.init();

frame.setSize(300,300);

frame.show();

}

public simple(String name)

{

super(name);

addWindowListener(new WindowAdapter()

{ public void windowClosing(WindowEvent e)

{______;

}

} );

}

public void init()

{

setLayout(new______);

Label labelTitle=new Label("在本文框中输入字符串, 可以早Frame中间显示");

Label showTextLabel=new Label();

TextField textField=new TextField("请在这里输入字符串");

textField.addActionListener(new AddStringListener(showTextLabel,

textField));

add("North", labelTitle);

add("Center", showTextLabel);

add("South", textField);

}

}

class AddStringListener implements ActionListener

{

Label label;

TextField textField;

public AddStringListener(Label label, TextField textField)

{

this.label=label;

this.textField=textField;

}

public void actionperformed(ActionEvent e)

{

label.setText(textField.getText());

}

}

点击查看答案

第6题

当生成StringBuffer的一个对象后,还可用______方法或ensureCapacity( )方法来设定缓存大小。

点击查看答案

第7题

设有数组定义:int a[ ]={11,22,33,44,55,66,77,88,99};则执行下列几条语句后的输出结果是 ______

for(int i=0;i<a.length;i++)

if(a[i]%3==0)System.out.println(a[i]+" ");

点击查看答案

第8题

按照Java的线程模型,代码和______构成了线程体。

点击查看答案

第9题

在数据库技术中,实体集之间的联系可以是一对一或一对多的,那么“学生”和“可选课程”的联系为______

点击查看答案

第10题

下面是一个Applet程序,设置其宽高为300和300像素,程序的功能是在小程序界面画一根水平线和一根垂

直线,将小程序界面均分为4个区域,鼠标在不同的区域移动时显示不同的几何图形。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。

注意:不改动程序的结构,不得增行或删行。

程序运行结果如下:

import java.awt.*;

import java.awt.Graphics.*;

import java.awt.event.*;

/*

<applet code=AppletPrograming width=200 height=200>

</applet>

*/

public class AppletPrograming extends Applet{

int m=-1,n=-1;

public void init()

{

addMouseMotionListener(new MouseMotionAdapter()

{

public void mouseMoved(Mouse p)

{

m=e.getX();

n=e.getY ( );

}

repaint ( )

{ }

});

}

public void paint(Graphics g)

{

g.drawLine(100,0,100,200);

g.drawLine(0,100,200,100);

if(m<100&&n<100)

{

g.setColor(Color.black);

g.fillOval(10,10,80,80);

}

else if(m>100&&n<100)

{

g.setColor(Color.green);

g.fillRect(110,10,80,80);

}

else if(m<100&&n>100)

{

g.setColor(Color.blue);

g.fillArc(10,130,80,35,50,250);

}

else if(m>100&&n>100)

{

int xvals[ ]={150,180,120};

int yvals[ ]={120,170,170};

g.setColor(Color.yellow);

g.fillPolygon(xvals,yvals,3);

}

}

}

ex35_3.html:

<html>

<head>

<title>A Simple Program</title>

</head>

<body>

<applet code="AppletPrograming.class"width=800 height=400>

</applet>

</body>

</html>

点击查看答案
下载上学吧APP
客服
TOP
重置密码
账号:
旧密码:
新密码:
确认密码:
确认修改
购买搜题卡查看答案
购买前请仔细阅读《购买须知》
请选择支付方式
微信支付
支付宝支付
选择优惠券
优惠券
请选择
点击支付即表示你同意并接受《服务协议》《购买须知》
立即支付
搜题卡使用说明

1. 搜题次数扣减规则:

功能 扣减规则
基础费
(查看答案)
加收费
(AI功能)
文字搜题、查看答案 1/每题 0/每次
语音搜题、查看答案 1/每题 2/每次
单题拍照识别、查看答案 1/每题 2/每次
整页拍照识别、查看答案 1/每题 5/每次

备注:网站、APP、小程序均支持文字搜题、查看答案;语音搜题、单题拍照识别、整页拍照识别仅APP、小程序支持。

2. 使用语音搜索、拍照搜索等AI功能需安装APP(或打开微信小程序)。

3. 搜题卡过期将作废,不支持退款,请在有效期内使用完毕。

请使用微信扫码支付(元)
订单号:
遇到问题请联系在线客服
请不要关闭本页面,支付完成后请点击【支付完成】按钮
遇到问题请联系在线客服
恭喜您,购买搜题卡成功 系统为您生成的账号密码如下:
重要提示: 请勿将账号共享给其他人使用,违者账号将被封禁。
发送账号到微信 保存账号查看答案
怕账号密码记不住?建议关注微信公众号绑定微信,开通微信扫码登录功能
警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

- 微信扫码关注上学吧 -
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反上学吧购买须知被冻结。您可在“上学吧”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
- 微信扫码关注上学吧 -
请用微信扫码测试
选择优惠券
确认选择
谢谢您的反馈

您认为本题答案有误,我们将认真、仔细核查,如果您知道正确答案,欢迎您来纠错

上学吧找答案