全国2011年10月自学考试Java语言程序设计试题

上传人:tia****nde 文档编号:36855975 上传时间:2018-04-03 格式:DOC 页数:9 大小:56.50KB
返回 下载 相关 举报
全国2011年10月自学考试Java语言程序设计试题_第1页
第1页 / 共9页
全国2011年10月自学考试Java语言程序设计试题_第2页
第2页 / 共9页
全国2011年10月自学考试Java语言程序设计试题_第3页
第3页 / 共9页
全国2011年10月自学考试Java语言程序设计试题_第4页
第4页 / 共9页
全国2011年10月自学考试Java语言程序设计试题_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《全国2011年10月自学考试Java语言程序设计试题》由会员分享,可在线阅读,更多相关《全国2011年10月自学考试Java语言程序设计试题(9页珍藏版)》请在金锄头文库上搜索。

1、 各类考试历年试题答案免费免注册直接下载全国 2011 年 10 月自学考试 Java 语言程序设计(一)试题1中国自考人()-700 门自考课程 永久免费、完整 在线学习 快快加入我们吧!全国全国 2011 年年 10 月自学考试月自学考试JavaJava 语言程序设计语言程序设计( (一一) )试题试题课程代码:04747一、单项选择题(本大题共 10 小题,每小题 1 分,共 1O 分)在每小题列出的四个备选项中只有一个是符合题目要求的,请将其代码填写在题后的括号内。错选、多选或未 选均无分。1下面供选字符序列中,不属于 Java 语言关键字的是 ( )A. throw B. synch

2、ronizedC. protect D. try2以下程序代码的输出的结果是 ( )double x = 25.6;System.out.println(int)x = KeyEvent.VK_A public void keyTyped(KeyEvent e) public void keyReleased(KeyEvent e) 30以下程序的界面有一个文本区 text,一个按钮 button。程序运行时,单击按钮,则将文本区中的内容输出到 out,其中 out 为 BufferWriter 类的一个对象。public void actionPerformed(ActionEvent e)

3、String s;if(e._= button)try out. _(text.getText(),0,(text.getText().length();out. flush();text.setText(null);System.exit(0); catch(IOException exp)text.setText(“文件定出错! n“); System.exit(-1);31数据库连接方法 connectByJdbcOdbc()按给定的数据库 URL、用户名和密码连接数 各类考试历年试题答案免费免注册直接下载全国 2011 年 10 月自学考试 Java 语言程序设计(一)试题5据库,如果

4、连接成功,方法返回连接对象,连接不成功,则返回空。public static Connection connectByJdbcOdbc(String url, String usemame, String password)Connection con = null;try Class. _(“sun.jdbc.odbc.JdbcOdbcDriver“); catch (Exception e) e.printStackTrace();return null;try con =_.getConnection(url, usemame, password);catch (SQLException

5、 e) e.printStackTrace();return null;return con;五、程序分析题(本大题共 5 小题,每小题 4 分,共 20 分)32阅读下列程序,请写出该程序的输出结果。class Test32a String name; int age; long number;Test32a(long number, String name,int age) System.out.println(“Name: “+name);System. out. println(“Age: “+age);System.out.println(“Tel: “ +number);class

6、 Test32b extends Test32a Test32b(long number, String name,int age,boolean b) 各类考试历年试题答案免费免注册直接下载全国 2011 年 10 月自学考试 Java 语言程序设计(一)试题6super(number, name,age); System.out.println(“Married: “+b);public class Test32 public static void main(String args) Test32b abe=new Test32b(4747,“Tony“,29,true);33阅读下列

7、程序,请写出该程序的输出结果。class Test33 String myString = “1“;public static void main(String args)Test33 myObj = new Test33();myObj.stringModifier(myObj.myString);System.out.println(“ “+ myObj.myString);void stringModifier(String theString)theString = theString + “2“; System.out.print(theString);34阅读下列程序,请写出该程序

8、的功能。import java.awt.*; import java.awt.event.*; import java.applet.*;public class Test34 extends Applet implements ActionListener String msg = “; Button bList = new Button3;public void init() Button yes = new Button(“Yes“); Button no = new Button(“No“);Button maybe = new Button(“Undecided“);bList0 =

9、 (Button) add(yes); bList 1 = (Button) add(no);bList2 = (Button) add(maybe);for(inti= 0;i 3; i+) bListi.addActionListener(this); 各类考试历年试题答案免费免注册直接下载全国 2011 年 10 月自学考试 Java 语言程序设计(一)试题7public void actionPerformed(ActionEvent ae) for(int i = 0;i 3; i+) if(ae.getSource() = bListi) msg = “You pressed “

10、+ bListi.getLabel();repaint();public void paint(Graphics g) g.drawString(msg, 6, 100); 35阅读下列程序,请写出该程序的功能。import java.awt.event.*; import javax.swing.*; import java.awt.*;public class MenuWindow extends JFrame implements ActionListener JTextField text = new JTextField();JMenuBar menuBar; JMenu menuF

11、ruits;JMenultem menultem1,menultem2,menultem3;public MenuWindow() menuBar = new JMenuBar(); setJMenuBar(menuBar);menuFruits = new JMenu(“水果“); menuBar.add(menuFruits);menultem 1 = new JMenultem(“苹果“); menultem1 .addActionListener(this);menuFruits.add(menultem1 );menultem2 = new JMenultem(“桔子“); menu

12、ltem2.addActionListener(this);menuFruits.add(menultem2); menuFruits.addSeparator();menultem3 = new JMenultem(“退出“); menultem3.addActionListener(this);menuFruits.add(menultem3);Container con = getContentPane();con.add(text); setSize(200,150); setVisible(true);public void actionPerformed(ActionEvent e

13、) 各类考试历年试题答案免费免注册直接下载全国 2011 年 10 月自学考试 Java 语言程序设计(一)试题8if (e.getActionCommand() = “退出“) System.exit(0);else text.setText(e.getActionCommand();public static void main(String args) MenuWindow mw = new MenuWindow();36阅读下列程序,请写出该程序的输出结果。class MyThread extends Thread String message; int s;MyThread(Str

14、ing message, int sec) this.message = message; s = sec; public void run( ) try sleep(s); catch(InterruptedException e)System.out.println(message+“ “+getPriority( );class ThreadTest public static void main(String args)Thread foo = new MyThread(“Foo“, 1000);foo.setPriority(Thread.MIN_PRIORITY); foo.sta

15、rt( );Thread bar = new MyThread(“Bar“,800);bar.setPriority(3); bar.start( );Thread gar = new MyThread(“Gar“,400);gar.setPriority(7); gar.start( );Thread kar = new MyThread(“Kar“, 100);kar.setPriority(Thread. MAX_PRIORITY); kar.start( );)注:假设处理机中没有其它线程占用资源。六、程序设计题(本大题共 2 小题,每小题 6 分,共 12 分) 各类考试历年试题答案免费免注册直接下载全国 2011 年 10 月自学考试 Java 语言程序设计(一)试题937.请编写一个方法 int findMaximum(intnumbers),要求该方法返回二维数

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 中学教育 > 试题/考题

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号