ImageVerifierCode 换一换
格式:DOC , 页数:8 ,大小:38.50KB ,
资源ID:1338238      下载积分:5000 积分
快捷下载
登录下载
邮箱/手机:
温馨提示:
如需开发票,请勿充值!快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝扫码支付 微信扫码支付   
注意:如需开发票,请勿充值!
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【http://www.mydoc123.com/d-1338238.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(【计算机类职业资格】计算机二级JAVA-145及答案解析.doc)为本站会员(amazingpat195)主动上传,麦多课文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文库(发送邮件至master@mydoc123.com或直接QQ联系客服),我们立即给予删除!

【计算机类职业资格】计算机二级JAVA-145及答案解析.doc

1、计算机二级 JAVA-145及答案解析(总分:100.00,做题时间:90 分钟)一、1基本操作题(总题数:1,分数:30.00)1.本题程序的功能是计算 110(包括 1和 10)中除 5以外各个自然数的和。请将下述程序补充完整(注意:不得改动程序的结构,不得增行或删行)。 public class basic public static void main (String args) int i = 1; int sum = 0; while(i = 10) if(i = 5) _; _; _; i+; System.out.println (“sum=“+sum); (分数:30.00)

2、二、2简单应用题(总题数:1,分数:40.00)2.本题程序的功能是通过滑动条修改颜色的 RGB值,从而控制颜色。程序中有一个面板、3 个标签和 3个滑动条,标签和滑动条一一对应,分别对应三原色红、绿、蓝,任意拖动其中的一个滑动条,所对应的颜色值就会发生变化,面板的颜色也会对应地发生变化。滑动条值的范围是 0255。请将下述程序补充完整(注意:不得改动程序的结构,不得增行或删行)。 import java.awt.*; import java.awt.event.*; import javax.swing.*; public class simple extends JFrame imple

3、ments AdjustmentListener public simple() setTitle(“simple“); setSize(300,200); addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) System.exit (0); ); Container contentPane =_; JPanel p = new JPane1(); p.setLayout(new GridLayout(3,2); p.add(redLabel = new JLabel(“Red 0“);

4、p.add(red = new JScrollBar(Adjustable.HORIZONTAL,0,0,0,255); red.setBlockIncrement(16); red.addAdjustmentListener(this); p.add(greenLabel = new JLabel(“Green 0“); p.add(green = new JScrollBar(Adjustable.HORIZONTAL,0,0,0,255); green.setBlockIncrement(16); green.addAdjustmentListener(this); p.add(blue

5、Label = new JLabel(“Blue 0“); p.add(blue = new JScrollBar(Adjustable.HORIZONTAL,0,0,0,255); blue.setBlockIncrement(16); blue.addAdjustmentListener(this); contentPane.add(p,“South“); colorPanel = new JPanel(); colorPanel.setBackground(new Color(0,0,0); contentPane.add(colorPanel,“Center“); public voi

6、d adjustmentValueChanged(AdjustmentEvent evt) redLabel.setText(“Red “ + red.getValue(); greenLabel.setText(“Green “ + green.getValue(); blueLabel.setText(“Blue “ + blue.getValue(); colorPanel.setBackground(new Color(red.getValue().green.getValue(),blue.getValue(); _; public static void main(String a

7、rgs) JFrame f = new simple(); f.show(); private JLabel redLabel; private JLabel greenLabel; private JLabel blueLabel; private JScrollBar red; private JScrollBar green; private JScrollBar blue; private JPanel colorPanel; (分数:40.00)_三、3综合应用题(总题数:1,分数:30.00)3.本题程序的功能是监听对于列表项的操作。窗口中有一个列表和“添加”、“删除”和“关闭”三

8、个按钮。单击“添加”按钮,会在当前所选列表项后添加一个名为“新增表项”的列表项,同时后台输入列表中的表项数量。单击“删除”按钮,如果未选中表项,则弹出提示消息框“请选择表项”,否则将选中的表项删除,同时后台输出删除表项的内容和列表中的表项数量。单击“关闭”按钮退出程序。程序中存在若干错误,请找出并改正(注意:不得改动程序的结构,不得增行或删行)。 import java.awt.*; import java.awt.event.*; import javax.swing.JOptionPane; public class advance public static void main(Stri

9、ng args) final Frame frmFrame = new Frame(); Panel pnlPanel1 = new Panel(); Panel pnlPanel2 = new Panel(); final List istList = new List(8); for(int i = 0; i 10; i+) String strName = “表项“ + (new Integer(i+1).toString(); istList.add( strName ); Button btnButton1 = new Button(“添加“); Button btnButton2

10、 new Button(“删除“); Button btnButton3 = new Button(“关闭“); btnButton1.addActionListener( new ActionListener() publiC void actionPerformed(ActionEvent e) lstList.add(“新增表项“,istList.getSelected()+1); System.out.println(“列表中的表项数量“ + istList,getItemCount() ); ); btnButton2.addActionListener (new ActionLi

11、stener () public void actionPerformed(ActionEvent e) if(istList.getSelected() = null) JOptionPane.showMessageDialog(frmFrame,“请选择表项“); return; System.out.println(“删除表项的内容:“+ istList,getSelectedItem(); istList.delete(istList.getSelectedIndex(); System.out.println(“列表中的表项数量: “ + istList,getItemCount (

12、); ); btnButton3.addActionListener(new ActionListener () public void actionPerformed(ActionEvent e) System.exit (0); ); pnlPanel1 .add (istList); pnlPanel2 .add (btnButton1); pnlPanel2 .add (btnButton2); pnlPanel2,add (btnButton3); frmFrame.add(“North“,pnlPanel1); frmFrame.add(“South“,pnlPanel2); fr

13、mFrame,setTitle (“advance“); frmFrame.pack (); frmFrame,show (); (分数:30.00)_计算机二级 JAVA-145答案解析(总分:100.00,做题时间:90 分钟)一、1基本操作题(总题数:1,分数:30.00)1.本题程序的功能是计算 110(包括 1和 10)中除 5以外各个自然数的和。请将下述程序补充完整(注意:不得改动程序的结构,不得增行或删行)。 public class basic public static void main (String args) int i = 1; int sum = 0; while

14、i = 10) if(i = 5) _; _; _; i+; System.out.println (“sum=“+sum); (分数:30.00)_正确答案:()解析:i+。 continue。 sum=sum+i。二、2简单应用题(总题数:1,分数:40.00)2.本题程序的功能是通过滑动条修改颜色的 RGB值,从而控制颜色。程序中有一个面板、3 个标签和 3个滑动条,标签和滑动条一一对应,分别对应三原色红、绿、蓝,任意拖动其中的一个滑动条,所对应的颜色值就会发生变化,面板的颜色也会对应地发生变化。滑动条值的范围是 0255。请将下述程序补充完整(注意:不得改动程序的结构,不得增行或删行

15、)。 import java.awt.*; import java.awt.event.*; import javax.swing.*; public class simple extends JFrame implements AdjustmentListener public simple() setTitle(“simple“); setSize(300,200); addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) System.exit (0); ); Container con

16、tentPane =_; JPanel p = new JPane1(); p.setLayout(new GridLayout(3,2); p.add(redLabel = new JLabel(“Red 0“); p.add(red = new JScrollBar(Adjustable.HORIZONTAL,0,0,0,255); red.setBlockIncrement(16); red.addAdjustmentListener(this); p.add(greenLabel = new JLabel(“Green 0“); p.add(green = new JScrollBar

17、Adjustable.HORIZONTAL,0,0,0,255); green.setBlockIncrement(16); green.addAdjustmentListener(this); p.add(blueLabel = new JLabel(“Blue 0“); p.add(blue = new JScrollBar(Adjustable.HORIZONTAL,0,0,0,255); blue.setBlockIncrement(16); blue.addAdjustmentListener(this); contentPane.add(p,“South“); colorPane

18、l = new JPanel(); colorPanel.setBackground(new Color(0,0,0); contentPane.add(colorPanel,“Center“); public void adjustmentValueChanged(AdjustmentEvent evt) redLabel.setText(“Red “ + red.getValue(); greenLabel.setText(“Green “ + green.getValue(); blueLabel.setText(“Blue “ + blue.getValue(); colorPanel

19、setBackground(new Color(red.getValue().green.getValue(),blue.getValue(); _; public static void main(String args) JFrame f = new simple(); f.show(); private JLabel redLabel; private JLabel greenLabel; private JLabel blueLabel; private JScrollBar red; private JScrollBar green; private JScrollBar blue

20、 private JPanel colorPanel; (分数:40.00)_正确答案:()解析:getContentPane()。 colorPanel.repaint()。三、3综合应用题(总题数:1,分数:30.00)3.本题程序的功能是监听对于列表项的操作。窗口中有一个列表和“添加”、“删除”和“关闭”三个按钮。单击“添加”按钮,会在当前所选列表项后添加一个名为“新增表项”的列表项,同时后台输入列表中的表项数量。单击“删除”按钮,如果未选中表项,则弹出提示消息框“请选择表项”,否则将选中的表项删除,同时后台输出删除表项的内容和列表中的表项数量。单击“关闭”按钮退出程序。程序中存在若干

21、错误,请找出并改正(注意:不得改动程序的结构,不得增行或删行)。 import java.awt.*; import java.awt.event.*; import javax.swing.JOptionPane; public class advance public static void main(String args) final Frame frmFrame = new Frame(); Panel pnlPanel1 = new Panel(); Panel pnlPanel2 = new Panel(); final List istList = new List(8); f

22、or(int i = 0; i 10; i+) String strName = “表项“ + (new Integer(i+1).toString(); istList.add( strName ); Button btnButton1 = new Button(“添加“); Button btnButton2 = new Button(“删除“); Button btnButton3 = new Button(“关闭“); btnButton1.addActionListener( new ActionListener() publiC void actionPerformed(Actio

23、nEvent e) lstList.add(“新增表项“,istList.getSelected()+1); System.out.println(“列表中的表项数量“ + istList,getItemCount() ); ); btnButton2.addActionListener (new ActionListener () public void actionPerformed(ActionEvent e) if(istList.getSelected() = null) JOptionPane.showMessageDialog(frmFrame,“请选择表项“); return;

24、 System.out.println(“删除表项的内容:“+ istList,getSelectedItem(); istList.delete(istList.getSelectedIndex(); System.out.println(“列表中的表项数量: “ + istList,getItemCount (); ); btnButton3.addActionListener(new ActionListener () public void actionPerformed(ActionEvent e) System.exit (0); ); pnlPanel1 .add (istLis

25、t); pnlPanel2 .add (btnButton1); pnlPanel2 .add (btnButton2); pnlPanel2,add (btnButton3); frmFrame.add(“North“,pnlPanel1); frmFrame.add(“South“,pnlPanel2); frmFrame,setTitle (“advance“); frmFrame.pack (); frmFrame,show (); (分数:30.00)_正确答案:()解析:第 23行的“lstList.getSelected()+1“改为“lstList.getSelectedIndex()+1“。 第 30行的“lstList.getSelected()=null“改为“lstList.getSelectedItem()=null“。 第 36行的“lstList.delete(lstList.getSelectedIndex()“改为“lstList.remove(lstList.get SelectedIndex()“。

copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1