欢迎来到麦多课文档分享! | 帮助中心 海量文档,免费浏览,给你所需,享你所想!
麦多课文档分享
全部分类
  • 标准规范>
  • 教学课件>
  • 考试资料>
  • 办公文档>
  • 学术论文>
  • 行业资料>
  • 易语言源码>
  • ImageVerifierCode 换一换
    首页 麦多课文档分享 > 资源分类 > DOC文档下载
    分享到微信 分享到微博 分享到QQ空间

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

    • 资源ID:1338238       资源大小:38.50KB        全文页数:8页
    • 资源格式: DOC        下载积分:5000积分
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    二维码
    微信扫一扫登录
    下载资源需要5000积分(如需开发票,请勿充值!)
    邮箱/手机:
    温馨提示:
    如需开发票,请勿充值!快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如需开发票,请勿充值!如填写123,账号就是123,密码也是123。
    支付方式: 支付宝扫码支付    微信扫码支付   
    验证码:   换一换

    加入VIP,交流精品资源
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    【计算机类职业资格】计算机二级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()“。


    注意事项

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




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

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

    收起
    展开