设为首页    加入收藏

自学考试省级导航

全国 A安徽 B北京 C重庆 F福建 G广东 广西 甘肃 贵州 H河南 河北 湖南 湖北 黑龙江 海南 J江苏 江西 吉林 L辽宁 N内蒙古 宁夏 Q青海 S山东 山西 陕西 四川 上海 T天津
     X新疆 西藏 Y云南 Z浙江 历年真题分类检索

全国2014年4月高等教育自学考试Java语言程序设计(一)真题(清晰word版)(五)
2015-02-09 20:07:20 来源:91考试网 作者:www.91exam.org 【

36.阅读下列程序,请回答以下问题:

(1)程序要求在文本框text中输入的内容是什么?

(2)程序采用什么输入方式下载网络文件?

import java.net.*; import java.awt.*;

import java.awt.event.*; import java.io.*; import javax.swing.*;

public class Test36{

public static void main(String args[]){

new ConnectNet("读取网络文本文件示意程序");

}

}

class ConnectNet extends JFrame implements ActionListener{

JTextField text = new JTextField(30);

JTextArea showArea=new JTextArea();

JButton b= new JButton("下载"); JPanel p= new JPanel();

ConnectNet(String s){

super(s);Container con = this.getContentPane();

p.add(text); p.add(b);

JScrollPane jsp = new JScrollPane(showArea);

b.addActionListener(this);

con.add(p,"North"); con.add(jsp, "Center");

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setSize(500, 400); setVisible(true);

}

public void actionPerformed(ActionEvent e){

String urlName=text.getText();

try{ URL url: new URL(urlName);∥由网址创建URL对象

URLConnection tc =url.openConnection();∥获得URLConnection对象

tc.connect();∥设置网络连接

InputStreamReader in =

new InputStreamReader(tc.getInputStream());

BufferedReader dis = new BufferedReader(in);

String inLine;

while((inLine=dis.readLine())!=null){

showArea.append(inLine+"");

}

dis.close();

} catch (MalformedURLException e2){e2.printStackTrace();}

catch(IOException e3){ e3.printStackTrace();}

}

}

六、程序设计题(本大题共2小题,每小题6分,共1 2分)

 
37.编写方法int[] arrayReverse(int[]a),该方法的功能是返回一个新的数组b,新数组的 元素排列顺序与参数数组的元素排列顺序相反。

38.类InputData是用于输入考生考号、课程和成绩的窗口,

窗口的界面如右图所示,其中三个文本框用来输入考号、课

程和成绩。

注:这里是给定程序的部分代码,你要编写的是完成该类的构

造方法。

import java.awt.*;import javax.swing.*;

import java.awt.event.*;

public class InputData extends JFrame implements ActionListener{

JTextField noText, markText, courseText;

JButton ok=new JButton("确 定");

public static int no, mark;∥让创建者直接获取考号和成绩

public static String course;∥让创建者直接获取课程名称

InputData(){

super("成绩输入窗");

Container con = getContentPane();

con.setLayout(new GridLayout(4, 1));

noText = new JTextField(12);

courseText = new JTextField(12);

markText = new JTextField(12);

∥请在答题纸相应位置编写代码

con.add(ok); ok.addActionListener(this);

con.setSize(250, 70); setVisible(true); pack();

}

public void actionPerformed(ActionEvent e) {

if (e.getSource() = ok) { ∥读取考号和成绩

no = Integer.parseInt(noText.getText());

course = courseText.getText();

mark = Integer.parseInt(markText.getText());

setVisible(false); dispose();

}

}

public static void main(String[] args) {

new InputData();

}

}

Tags:自学考试 历年真题
】【打印繁体】 【关闭】 【返回顶部
上一篇全国2012年10月自学考试Java语言.. 下一篇全国2013年10月自学考试《建筑经..

网站客服QQ: 960335752 - 14613519 - 48225117