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

上传人:Iclinic170 文档编号:1326521 上传时间:2019-10-17 格式:DOC 页数:6 大小:36KB
下载 相关 举报
【计算机类职业资格】二级JAVA机试-204及答案解析.doc_第1页
第1页 / 共6页
【计算机类职业资格】二级JAVA机试-204及答案解析.doc_第2页
第2页 / 共6页
【计算机类职业资格】二级JAVA机试-204及答案解析.doc_第3页
第3页 / 共6页
【计算机类职业资格】二级JAVA机试-204及答案解析.doc_第4页
第4页 / 共6页
【计算机类职业资格】二级JAVA机试-204及答案解析.doc_第5页
第5页 / 共6页
点击查看更多>>
资源描述

1、二级 JAVA 机试-204 及答案解析(总分:100.00,做题时间:90 分钟)一、1基本操作题(总题数:1,分数:30.00)1.本题程序的功能是读入运行程序时所传入的参数(一个或多个),并将参数依次显示出来。例如运行程序“lava basic par1 par2”,则打印输出为“par1 par2”。请将下述程序补充完整(注意:不得改动程序的结构,不得增行或删行)。public class basicpublic static void main(String args)int i = 0;while (_)System.out.print(_+ “);_;System.out.pri

2、ntln();(分数:30.00)_二、2简单应用题(总题数:1,分数:40.00)2.本题程序的功能是利用单选按钮选择性别,并在下面显示用户的选择结果。请将下述程序补充完整(注意:不得改动程序的结构,不得增行或删行)。import java.awt.*;_;public class simplepublic static void main (String args)Frame f = new Frame (“simple“);f.setLayout (new GridLayout(3,1);f.addWindowListener(new WindowAdapter() public voi

3、d windowClosing(WindowEvent e)System.exit (0););CheckboxGroup cg = new CheckboxGroup();Checkbox male = new Checkbox(“男“,cg,false);Checkbox female = new Checkbox(“女“,cg,false);final Label la = new Label(“请选择你的性别“);male.addItemListener(new ItemListener() public void itemStateChanged(ItemEvent e)la.set

4、Text (“你是个男生“););female.addItemListener(new ItemListener() public void itemStateChanged(ItemEvent e)la.setText (“你是个女生“););f.add(male);f.add(female);f.add(la);f.setSize(200,200);_;(分数:40.00)_三、3综合应用题(总题数:1,分数:30.00)3.本题程序的功能是监听对于列表项的操作。窗口中有一个列表和“添加”、“删除”和“关闭”三个按钮。单击“添加”按钮,会在当前所选列表项后添加一个名为“新增表项”的列表项,

5、同时后台输入列表中的表项数量。单击“删除”按钮,如果未选中表项,则弹出提示消息框“请选择表项”,否则将选中的表项删除,同时后台输出删除表项的内容和列表中的表项数量。单击“关闭”按钮退出程序。程序中存在若干错误,请找出并改正(注意:不得改动程序的结构,不得增行或删行)。import java.awt.*;import java.awt.event.*;import javax.swing.JOptionPane;public class advancepublic static void main(String args)final Frame frmFrame = new Frame();Pa

6、nel 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 = new Button(“删除“);Button btnButton3 = new Button(“关闭“

7、);btnButton1.addActionListener( new ActionListener() publiC void actionPerformed(ActionEvent e)lstList.add(“新增表项“,istList.getSelected()+1);System.out.println(“列表中的表项数量“ + istList,getItemCount() ););btnButton2.addActionListener (new ActionListener () public void actionPerformed(ActionEvent e)if(istLi

8、st.getSelected() = null)JOptionPane.showMessageDialog(frmFrame,“请选择表项“);return;System.out.println(“删除表项的内容:“+ istList,getSelectedItem();istList.delete(istList.getSelectedIndex();System.out.println(“列表中的表项数量: “ + istList,getItemCount (););btnButton3.addActionListener(new ActionListener () public void

9、 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);frmFrame,setTitle (“advance“);frmFrame.pack ();frmFrame,show ();(分数:30.00)_二级 J

10、AVA 机试-204 答案解析(总分:100.00,做题时间:90 分钟)一、1基本操作题(总题数:1,分数:30.00)1.本题程序的功能是读入运行程序时所传入的参数(一个或多个),并将参数依次显示出来。例如运行程序“lava basic par1 par2”,则打印输出为“par1 par2”。请将下述程序补充完整(注意:不得改动程序的结构,不得增行或删行)。public class basicpublic static void main(String args)int i = 0;while (_)System.out.print(_+ “);_;System.out.println(

11、);(分数:30.00)_正确答案:(iargs.length。argsi。i+。)解析:二、2简单应用题(总题数:1,分数:40.00)2.本题程序的功能是利用单选按钮选择性别,并在下面显示用户的选择结果。请将下述程序补充完整(注意:不得改动程序的结构,不得增行或删行)。import java.awt.*;_;public class simplepublic static void main (String args)Frame f = new Frame (“simple“);f.setLayout (new GridLayout(3,1);f.addWindowListener(new

12、 WindowAdapter() public void windowClosing(WindowEvent e)System.exit (0););CheckboxGroup cg = new CheckboxGroup();Checkbox male = new Checkbox(“男“,cg,false);Checkbox female = new Checkbox(“女“,cg,false);final Label la = new Label(“请选择你的性别“);male.addItemListener(new ItemListener() public void itemStat

13、eChanged(ItemEvent e)la.setText (“你是个男生“););female.addItemListener(new ItemListener() public void itemStateChanged(ItemEvent e)la.setText (“你是个女生“););f.add(male);f.add(female);f.add(la);f.setSize(200,200);_;(分数:40.00)_正确答案:(importjava.awt.event.*。f.setVisible(true)。)解析:三、3综合应用题(总题数:1,分数:30.00)3.本题程序

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

15、dvancepublic static void main(String 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

16、添加“);Button btnButton2 = 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.addActionLis

17、tener (new ActionListener () 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,g

18、etItemCount (););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);

19、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()“。)解析:

展开阅读全文
相关资源
猜你喜欢
  • EN ISO 16995-2015 en Solid biofuels - Determination of the water soluble chloride sodium and potassium content《固体生物燃料 水溶性氯 钠和钾含量的测定(ISO 16995 2015)》.pdf EN ISO 16995-2015 en Solid biofuels - Determination of the water soluble chloride sodium and potassium content《固体生物燃料 水溶性氯 钠和钾含量的测定(ISO 16995 2015)》.pdf
  • EN ISO 17034-2016 en General requirements for the competence of reference material producers《对标准物质生产能力的一般要求(ISO 17034 2016)》.pdf EN ISO 17034-2016 en General requirements for the competence of reference material producers《对标准物质生产能力的一般要求(ISO 17034 2016)》.pdf
  • EN ISO 17059-2009 en Oilseeds - Extraction of oil and preparation of methyl esters of triglyceride fatty acids for analysis by gas chromatography (Rapid method)《含油种子 气相色谱法分析用油的萃取和甘.pdf EN ISO 17059-2009 en Oilseeds - Extraction of oil and preparation of methyl esters of triglyceride fatty acids for analysis by gas chromatography (Rapid method)《含油种子 气相色谱法分析用油的萃取和甘.pdf
  • EN ISO 17070-2015 en Leather - Chemical tests - Determination of tetrachlorophenol- trichlorophenol- dichlorophenol- monochlorophenol-isomers and pentachlorophenol content《皮革 化学测试 .pdf EN ISO 17070-2015 en Leather - Chemical tests - Determination of tetrachlorophenol- trichlorophenol- dichlorophenol- monochlorophenol-isomers and pentachlorophenol content《皮革 化学测试 .pdf
  • EN ISO 17071-2011 en Leather - Physical and mechanical tests - Determination of fogging characteristics《皮革 物理和机械试验 雾化特性的测定》.pdf EN ISO 17071-2011 en Leather - Physical and mechanical tests - Determination of fogging characteristics《皮革 物理和机械试验 雾化特性的测定》.pdf
  • EN ISO 17072-1-2011 en Leather - Chemical determination of metal content - Part 1 Extractable metals《皮革 化学测定金属含量 第1部分 可提取金属》.pdf EN ISO 17072-1-2011 en Leather - Chemical determination of metal content - Part 1 Extractable metals《皮革 化学测定金属含量 第1部分 可提取金属》.pdf
  • EN ISO 17072-2-2011 en Leather - Chemical determination of metal content - Part 2 Total metal content《皮革 金属含量的化学测定 总金属含量》.pdf EN ISO 17072-2-2011 en Leather - Chemical determination of metal content - Part 2 Total metal content《皮革 金属含量的化学测定 总金属含量》.pdf
  • EN ISO 17074-2011 en Leather - Physical and mechanical tests - Determination of resistance to horizontal spread of flame《皮革 物理和机械试验 火焰抗水平传播性的测定》.pdf EN ISO 17074-2011 en Leather - Physical and mechanical tests - Determination of resistance to horizontal spread of flame《皮革 物理和机械试验 火焰抗水平传播性的测定》.pdf
  • EN ISO 17075-1-2017 en Leather - Chemical determination of chromium(VI) content in leather - Part 1 Colorimetric method《皮革铬(VI)的化学测定皮革中的第1部分内容 比色法(ISO 17075-1 2017)》.pdf EN ISO 17075-1-2017 en Leather - Chemical determination of chromium(VI) content in leather - Part 1 Colorimetric method《皮革铬(VI)的化学测定皮革中的第1部分内容 比色法(ISO 17075-1 2017)》.pdf
  • 相关搜索

    当前位置:首页 > 考试资料 > 职业资格

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