已阅读5页,还剩2页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
全国2011年10月高等教育自学考试Java语言程序设计(一)试题一、单项选择题(本大题共10小题,每小题1分,共1O分) 在每小题列出的四个备选项中只有一个是符合题目要求的,请将其代码填写在题后的括号内。错选、多选或未 选均无分。1下面供选字符序列中,不属于Java语言关键字的是 ( )A. throw B. synchronizedC. protect D. try2以下程序代码的输出的结果是 ( )double x = 25.6;System.out.println(int)x = KeyEvent.VK_A &t= KeyEvent.VK_Z)text.append(char)t+ ); public void keyTyped(KeyEvent e) public void keyReleased(KeyEvent e) 30以下程序的界面有一个文本区text,一个按钮button。程序运行时,单击按钮,则 将文本区中的内容输出到out,其中out为BufferWriter类的一个对象。public void actionPerformed(ActionEvent e) 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、用户名和密码连接数 据库,如果连接成功,方法返回连接对象,连接不成功,则返回空。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 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 Test32b extends Test32a Test32b(long number, String name,int age,boolean b) super(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阅读下列程序,请写出该程序的输出结果。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阅读下列程序,请写出该程序的功能。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 = (Button) add(yes); bList 1 = (Button) add(no); bList2 = (Button) add(maybe); for(inti= 0;i 3; i+) bListi.addActionListener(this); public void actionPerformed(ActionEvent ae) for(int i = 0;i 3; i+) if(ae.getSource() = bListi) msg = You pressed + 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 menuFruits; 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(桔子); menultem2.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) if (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(String 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.start( ); 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分)37.请编写一个方法int findMaximum(intnumbers),要求该方法返回二维数组中元素的最大值。38小应用程序的paint(Gmphics g)方法能在屏幕窗口上显示信息和绘图,如果paint()方法能调用repaint()方法,这就能使显示实现动态效果,repaint()方法的功能是先清除paint()方法以前所画的内容,然后再调用paint()方法。 以
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 20261029-102548-苏教版高二生物选择性必修3生物技术与工程寒假作业(含答案)
- (新版)海洋石油天然气开采安全管理人员考试题库(含答案)
- 2025安全生产管理小微企业试题及答案
- 2022年全国4月自考思想道德修养与法律基础答案
- 2024年安徽公务员公务员行测考试真题及答案
- 《2025年锻造工(技能鉴定)实战试题》
- (2026)医务人员手卫生规范培训考试试题及答案
- (2025年)全面质量管理知识考试题库及答案
- (2025年)中医执业助理医师实践技能第一站样题及答案解析
- 工业废气处理设施运行优化手册
- 北京2026年11月小学五年级数学期中试卷及答案
- 人教版八年级英语上册Unit1-Unit 8语法知识点+练习题(含答案)
- 《盘活存量土地和低效用地典型案例2026版》
- 医务人员手卫生规范(WS-T313-2019)
- 2027年江苏省高职单招职业技能考试题库附完整答案详解(考点梳理)
- 叉车司机五级试题+参考答案
- 山东灯塔e支部录入培训课件
- 2026年海南科技职业大学单招职业技能考试备考试题附答案详解
- 2024年云南省选调公务员笔试真题汇编含答案解析(夺冠)
- 合并CKD的冠心病糖尿病患者血运重建方案
- 物业服务标准化培训课件
评论
0/150
提交评论