2011年全国自考Java语言程序设计(一)模拟试卷(一)及答案.doc

上传人:啊飒飒 文档编号:10717482 上传时间:2021-06-01 格式:DOC 页数:26 大小:255KB
返回 下载 相关 举报
2011年全国自考Java语言程序设计(一)模拟试卷(一)及答案.doc_第1页
第1页 / 共26页
2011年全国自考Java语言程序设计(一)模拟试卷(一)及答案.doc_第2页
第2页 / 共26页
2011年全国自考Java语言程序设计(一)模拟试卷(一)及答案.doc_第3页
第3页 / 共26页
2011年全国自考Java语言程序设计(一)模拟试卷(一)及答案.doc_第4页
第4页 / 共26页
2011年全国自考Java语言程序设计(一)模拟试卷(一)及答案.doc_第5页
第5页 / 共26页
点击查看更多>>
资源描述

《2011年全国自考Java语言程序设计(一)模拟试卷(一)及答案.doc》由会员分享,可在线阅读,更多相关《2011年全国自考Java语言程序设计(一)模拟试卷(一)及答案.doc(26页珍藏版)》请在三一文库上搜索。

1、更多优质自考资料尽在百度贴吧自考乐园俱乐部(http:/ 在每小题列出的四个备选项中只有一个是符合题目要求的,请将其代码填写在题后的括号内。错选、多选或未选均无分。1.在Java中,负责对字节代码解释执行的是() (1分)A:垃圾回收器B:虚拟机C:编译器D:多线程机制2.在编写Java applet程序时,若需要对发生事件作出响应和处理,一般需要在程序的开头写上的语句是() (1分)A:import java.awt.*;B:import java.applet.*;C:import java.io.*;D:import java.awt.event.*;3.Java中实现输入/输出操作的类

2、库在() (1分)A:java.io包中B:java.input包中C:java.output包中D:java.lang.io包中4.以下程序代码的输出结果是() System.out.println(100/8); (1分)A:12.5B:12C:4D:05.能够支持 javadoc 命令的文档注释形式是() (1分)A:/*./B:/*.*/C:/D:/*.*/6.Java组件可以使用Toolkit提供的静态方法获得一个缺省的Toolkit对象,并用它加载图像,这个静态方法是() (1分)A:getImage(String name)B:getImage(URL url)C:getDefa

3、ultToolkit()D:getToolkit()7.在Java中,线程的调度策略采用() (1分)A:分时式B:抢占式C:非分时式D:非抢占式8.在Java程序中,已将FileWriter对象接到BufferedWriter对象上,要实现缓冲式输出,可对BufferedWriter对象使用的方法是() (1分)A:read()B:write()C:readLine()D:writeLong()9.菜单的事件源是用鼠标点击某个菜单项,ActionListener,要实现的接口方法是actionPerformed(ActionEvent e),获得事件源的方法是getSource(),处理该事

4、件的接口是() (1分)A:ActionListenerB:actionPerformedC:getSourceD:ItemListener10.采用缓冲式输出时,如果又想立即写入到文件,则需要调用的方法是() (1分)A:flash()B:flush()C:write()D:read()二、填空题(本大题共10小题,每小题2分,共20分)请在每小题的空格中填上正确答案。错填、不填均无分。1.在switch 语句中,通过语句退出 switch 语句,使程序从整个 switch 语句后面的第一条语句处开始执行。 (2分)2.为选择框(JCheckBox)对象设定监视器的方法是:。 (2分)3.当

5、把Java的绘图模式设置为异或模式红色,并对同一个圆用同一个颜色绿色绘制两遍时,则此圆的绘制情况是:。 (2分)4.JDBC是java程序与数据库连接的API,它可以与某个数据库建立连接、向数据库发送SQL语句和。 (2分)5.Java语言提供一个Graphics2D类,这个类定义了几种方法用于添加或改变图形的状态属性,其中属性控制线条的宽度、笔形样式、线段连接方式或短划线图案。 (2分)6.多线程互斥使用共享资源的程序段,称为,它是一种加锁机制,与多线程共享资源有关,它的作用是在任何时该一个共享资源只能供一个线程使用。 (2分)7.在Java语言中,整型常量有十进制、八进制和十六进制三种写法

6、,其中八进制是以数字字符0开头,十六进制是以开头。 (2分)8.以下代码的输出结果是。 System.out.println(54=3=200) redSeta=0; x=0; y=redSeta; redPen.setColor(Color.red); redPen.fillOval(100+x,y,10,10); try redBall.sleep(20); catch(InterruptedException e) else if() x=0; y=blueSeta; bluePen.setColor(Color.gray); bluePen.fillOval(150+x,100+y,1

7、0,10); blueSeta-=3; if(blueSeta=-100) blueSeta=0; x=0; y=blueSeta; bluePen.setColor(Color.blue); bluePen.fillOval(150+x,100+y,10,10); try blueBall.sleep(40); catch(InterruptedException e) (2分)4.下面是一个求:1/1+1/2+2/3+3/5+5/8+8/13+13/21+21/32前20项的和的程序段 float a=1,b=1,s=0; for(int k=1;k=10;k+) s=s+a/b; a=

8、s=s+b/a; b= System.out.println(s); (2分)5.以下程序产生一个确认对话框。 import javax.swing.*; public class Class2905 public static void main(String args) JFrame myWin=new JFrame(); myWin.setBounds(100,100,200,300); myWin.setVisible(true); myWin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); int resule=.(myWin, 确实要

9、退出吗?,退出确认,0); System.out.println(resule); (2分)四、程序分析题(本大题共5小题,每小题4分,共20分)1.阅读下面程序,画出程序运行后的布局设计。 import java.awt.*; import javax.swing.*; public class Class3501 public static void main(String args) JFrame myWin=new JFrame(Class3501); myWin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container con

10、=myWin.getContentPane(); con.setLayout(new GridLayout(1,3); JTextArea textA=new JTextArea(TextArea,3,5); JScrollPane jsp=new JScrollPane(textA); con.add(jsp); JPanel jp=new JPanel(); jp.setLayout(new GridLayout(2,1); JLabel label=new JLabel(JLabel); JTextField text=new JTextField(Text); jp.add(label

11、);jp.add(text); con.add(jp); JButton button=new JButton(JButton); con.add(button); myWin.pack(); myWin.setVisible(true); (4分)2.阅读下列程序,画出程序运行后初始界面并写出程序功能。 import java.applet.*; import java.awt.*; import java.awt.event.*; public class Class3603 extends Applet implements ActionListener AudioClip clip;

12、Button buttonPlay,buttonLoop,buttonStop; public void init() clip=getAudioClip(getCodeBase(),windowsXP关机.wav); buttonPlay=new Button(start); buttonLoop=new Button(loop); buttonStop=new Button(stop); buttonPlay.addActionListener(this); buttonStop.addActionListener(this); buttonLoop.addActionListener(t

13、his); setSize(300,100); add(buttonPlay);add(buttonLoop);add(buttonStop); public void stop() clip.stop(); public void actionPerformed(ActionEvent e) if(e.getSource()=buttonPlay)clip.play(); else if(e.getSource()=buttonLoop)clip.loop(); if(e.getSource()=buttonStop)clip.stop(); (4分)3.阅读下列程序,写出程序运行结果。 i

14、nterface Computable final int MAX=100; int f(int x); int g(int x,int y); class Aa implements Computable int no; public int f(int x) int sum=0; for(int i=1;i=x;i+)sum=sum+i; return sum; public int g(int x,int y)return x*y; class Bb implements Computable int no; public int f(int x) int sum=0; for(int

15、i=1;i4=3=200) redSeta=0;x=0;y=redSeta;redPen.setColor(Color.red);redPen.fillOval(100+x,y,10,10);try redBall.sleep(20);catch(InterruptedException e)else if(_)x=0;y=blueSeta;bluePen.setColor(Color.gray);bluePen.fillOval(150+x,100+y,10,10);blueSeta-=3;if(blueSeta=-100) blueSeta=0;x=0;y=blueSeta;bluePen.setColor(Color.blue);bluePen.fillOval(150+x,100+y,10,10);try blueBall.sleep(40);catch(InterruptedException e)4:参考答案:a=a+b; b=a+b;试题内容:下面是一个求:1/1+1/2+2/

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1